CircleCI-Public / trigger-circleci-pipeline-action

Trigger a CircleCI pipeline from any GitHub Actions event.
https://github.com/marketplace/actions/trigger-circleci-pipeline
48 stars 43 forks source link

Bug: CircleCI checkout fails when triggered on pull_request_review #36

Closed kelvintaywl closed 1 year ago

kelvintaywl commented 1 year ago

Is there an existing issue for this?

Current behavior

I am not 100% sure this is a bug or perhaps more of a feature-request, but am filing an issue on behalf of a customer πŸ™‡

Given the following Github workflow config:

name: Trigger CircleCI

on:
  pull_request_review:
    types: [submitted]
jobs:
  trigger-circleci:
    if: github.event.review.state == 'approved'
    runs-on: ubuntu-latest
    steps:
      - name: on PR review
        id: circleci_on_github_pr_review
        uses: CircleCI-Public/trigger-circleci-pipeline-action@v1.0.5
        env:
          CCI_TOKEN: ${{ secrets.CCI_TOKEN }}

When a PR is approved, this GitHub Action is triggered. However, we see the following error on the subsequent CircleCI pipeline when checkout as the branch value for TriggerPipeline API is refs/pull<PR number>/merge:

Checking out branch
fatal: reference is not a tree: 74f97585e2e344a232fa48ea118bedf8ee6fd94f

exit status 128

Ref: https://app.circleci.com/pipelines/github/kelvintaywl-cci/circleci-gha-explore/8/workflows/cddf2112-2c4a-4828-986a-97dca5cb6e15/jobs/3?invite=true#step-101-81

Based on the TriggerPipeline API documentation, I wonder if the branch value should be:

- refs/pull/<PR number>/merge
+ pull/<PR number>/merge

Minimum reproduction code

https://github.com/kelvintaywl-cci/circleci-gha-explore/pull/2

Steps to reproduce

No response

Expected behavior

I am expecting that the CircleCI pipeline's job to be able to checkout successfully.

GitHub Action Version

1.0.5

Other

No response

kelvintaywl commented 1 year ago

for clarity, we can see more details about the above triggered CircleCI pipeline via API:

$ curl -X GET -H "circle-token: $CIRCLE_TOKEN" https://circleci.com/api/v2/project/github/kelvintaywl-cci/circleci-gha-explore/pipeline/8

{
  "id" : "b0bb6d30-367a-4fca-8bea-c30449c56c1b",
  "errors" : [ ],
  "project_slug" : "gh/kelvintaywl-cci/circleci-gha-explore",
  "updated_at" : "2022-12-13T09:29:57.352Z",
  "number" : 8,
  "state" : "created",
  "created_at" : "2022-12-13T09:29:57.352Z",
  "trigger" : {
    "received_at" : "2022-12-13T09:29:57.011Z",
    "type" : "api",
    "actor" : {
      "login" : "kelvintaywl",
      "avatar_url" : "https://avatars.githubusercontent.com/u/2164346?v=4"
    }
  },
  "vcs" : {
    "origin_repository_url" : "https://github.com/kelvintaywl-cci/circleci-gha-explore",
    "target_repository_url" : "https://github.com/kelvintaywl-cci/circleci-gha-explore",
    "revision" : "74f97585e2e344a232fa48ea118bedf8ee6fd94f",
    "provider_name" : "GitHub",
    "branch" : "refs/pull/2/merge"
  }
}
KyleTryon commented 1 year ago

Looks like any pull_request_* type event would be affected currently. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

kelvintaywl commented 1 year ago

thanks so much for investigating and making a fix so quickly #37 πŸ™‡ @KyleTryon πŸ‘