Triggering circle job via github PR action uses wrong SHA1

I’ve been working out a way to use CircleCI to build on branches and tags, and to use GitHub Actions to trigger a separate build when PRs are first opened. I have the following github pipeline:

name: New PR
on:
  pull_request:
    types: [opened]
jobs:
  trigger_circle:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: Trigger Build
        uses: CircleCI-Public/trigger-circleci-pipeline-action@v1.0.4
        env:
          CCI_TOKEN: ${{ secrets.CCI_TOKEN }}

This does trigger CircleCI successfully; however the circle job fails checking out the repo with the following:

Using SSH Config Dir '/home/circleci/.ssh'
git version 2.35.1
Cloning git repository
Cloning into '.'...
Warning: Permanently added the ECDSA host key for IP address '140.82.114.3' to the list of known hosts.
remote: Enumerating objects: 126, done.        
remote: Counting objects: 100% (126/126), done.        
remote: Compressing objects: 100% (72/72), done.        
remote: Total 126 (delta 46), reused 107 (delta 32), pack-reused 0        
Receiving objects: 100% (126/126), 554.94 KiB | 22.20 MiB/s, done.
Resolving deltas: 100% (46/46), done.
Checking out branch
fatal: reference is not a tree: 29b50badd2ab68b3dd60d1909e7b095a0f72a852

exit status 128

Doing a git log in the repo shows that the hash listed doesn’t exist and it took me a while to figure out where it came from. Turns out in the GH side of things, this command is running as part of the checkout action:

/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +29b50badd2ab68b3dd60d1909e7b095a0f72a852:refs/remotes/pull/7/merge

When I re-run the circle job with SSH, $CIRCLE_SHA1 is set to that hash but it’s only after I run the same command as the GH action that the checkout command (git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1") works.

So I guess my question is: is this integration even possible? It seems like the GH action is sending over that ref but I don’t know if the fix is to get it to send over a different ref or to tweak the circle job to pick a different sha1.

(And yes, I know that there’s an option to ONLY build pull requests, which I don’t think I want - I need to build PRs to deploy to one environment, and build releases (via tags) into a different environment, and I’m not sure if I can handle tag pushes if i’m only building PRs.)

The github repo that hosts trigger-circleci-pipeline-action may be the best place to post this

 https://github.com/CircleCI-Public/trigger-circleci-pipeline-action

The logic for saying this is that such posts will end up going to the developer who is working on/maintaining the code. There is also an outstanding issue that may be related.

Thanks, I’ve added an issue. Does appear there’s a PR that addresses either that issue or something similar revolving around refs, so I imagine that’s where it’ll be addressed.

Issue: Bug: ref not being persisted after checkout · Issue #18 · CircleCI-Public/trigger-circleci-pipeline-action · GitHub
Possible PR: Use head ref for PRs by nick-fields · Pull Request #16 · CircleCI-Public/trigger-circleci-pipeline-action · GitHub

v1.0.5 of the GH action (released today) fixes this.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.