-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests trigger: add target-branch parameter to trigger from the right branch #4121
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,27 @@ jobs: | |
fi | ||
echo "User is a member of the organization" | ||
|
||
|
||
# Note: actions based on issue comments always trigger from the main branch. So we need to tell CircleCI to use a specific branch. | ||
# We can do that by passing in the target-branch. | ||
# This solution is based on this comment: https://github.com/CircleCI-Public/trigger-circleci-pipeline-action/issues/61#issuecomment-1662021882 | ||
# But we can also see that the following code reads from this parameter: https://github.com/CircleCI-Public/trigger-circleci-pipeline-action/blob/a81cd720792a6088debd7f182b552845abb86f1b/src/lib/CircleCIPipelineTrigger.ts#L66 | ||
# Even though it seems to be undocumented as of writing. | ||
|
||
- name: 'Get GitHub branch' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: maybe this step can be named "Get PR branch"? "PR" is the relevant bit imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great call, updated! |
||
run: echo ::set-output name=branch::$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is, listed here: I'll add a comment that this assumes that it's installed, though, just in case it randomly gets removed one day, although I can't imagine that would ever be the case |
||
env: | ||
REPO: ${{ github.repository }} | ||
PR_NO: ${{ github.event.issue.number }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Trigger CircleCI workflow | ||
id: trigger_circleci_workflow | ||
if: success() | ||
|
||
uses: CircleCI-Public/[email protected] | ||
with: | ||
target-branch: ${{ steps.get-branch.outputs.branch }} | ||
GHA_Meta: "run-from-github-comments" | ||
env: | ||
CCI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit but there's an extra line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!