Open jblacker opened 1 year ago
This issue is actually mentioned in PR #11, but after it was merged. Figured it made sense to create a top-level ticket pointing out this issue.
Just ran into the same thing. You can use version 1.1.0 of this action and provide target-branch
as parameter.
Unfortunately you need to fetch the branch name manually beforehand. (ref: https://github.com/actions/checkout/issues/331)
This works for me:
name: pr comment
on:
issue_comment:
types: [created]
jobs:
deploy-dev:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/dev')
name: Deploy dev
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- id: 'get-branch'
run: echo ::set-output name=branch::$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger CircleCI
id: trigger-circleci
uses: CircleCI-Public/trigger-circleci-pipeline-action@v1.1.0
with:
target-branch: ${{ steps.get-branch.outputs.branch }}
env:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
@iwt-denniskribl
Just ran into the same thing. You can use version 1.1.0 of this action and provide
target-branch
as parameter.
Please could you add this to trigger-circleci-pipeline-action/examples/ ? I have been looking for a solution like this all day and this finally worked! My usecase is also a slash command as comment to trigger a workflow that should not normally run.
Is there an existing issue for this?
Current behavior
When I attempt to trigger a workflow in CircleCI from this GitHub Action on the created
issue_comment
event it works properly, but then starts the workflow on the incorrect branch within CircleCI. It appears to start the pipeline for the commit at HEAD ofmain
rather than on the branch/commit in the Pull Request that triggered the action.Minimum reproduction code
https://gist.github.com/jblacker/4f8b3d87b3b0b60a00c166e05d6ced81
Steps to reproduce
main
(or whatever your default is) rather than the head of the current branch of the PR.Expected behavior
I would have expected the branch that the PR is for to be triggered in CircleCI.
GitHub Action Version
1.0.5
Other
Here's the trigger on the CircleCI side of things: