Skip to content

Commit a940f77

Browse files
jpnurmicodexvaind
authored
fix(updater): Trigger CI for new PRs without changelog updates (#166)
* fix(updater): Trigger CI for new PRs without changelog updates New updater PRs can end with no branch update after creation when changelog entries are disabled. Amend and push the created PR commit in that case so GitHub emits a pull_request synchronize event. Fixes: #164 Co-Authored-By: OpenAI Codex <noreply@openai.com> * Update CHANGELOG.md * Update updater/action.yml Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com> --------- Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
1 parent 98c1e36 commit a940f77

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Fixes
1212

13+
- Updater - Trigger CI for new PRs without changelog updates ([#166](https://github.com/getsentry/github-workflows/pull/166))
1314
- Updater - Select the first branch when multiple branches point at `HEAD` ([#165](https://github.com/getsentry/github-workflows/pull/165))
1415

1516
### Dependencies

updater/action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,32 @@ runs:
462462
Auto-generated by a [dependency updater](https://github.com/getsentry/github-workflows/blob/main/updater/action.yml).
463463
${{ env.TARGET_CHANGELOG }}
464464
labels: dependencies
465+
466+
- name: Trigger PR workflows
467+
if: ${{ (inputs.changelog-entry != 'true') && ( steps.create-pr.outputs.pull-request-operation == 'created' ) && ( steps.update.outputs.pull-request-head-sha == '' || steps.update.outputs.pull-request-head-sha == steps.create-pr.outputs.pull-request-head-sha ) }}
468+
shell: bash
469+
working-directory: caller-repo
470+
env:
471+
PR_BRANCH: ${{ steps.root.outputs.prBranch }}
472+
PR_HEAD_SHA: ${{ steps.create-pr.outputs.pull-request-head-sha }}
473+
API_TOKEN: ${{ inputs.api-token }}
474+
SSH_KEY: ${{ inputs.ssh-key }}
475+
run: |
476+
git fetch origin "$PR_BRANCH"
477+
git checkout --force -B "$PR_BRANCH" "origin/$PR_BRANCH"
478+
479+
current_head=$(git rev-parse HEAD)
480+
if [ "$current_head" != "$PR_HEAD_SHA" ]; then
481+
echo "::notice::PR branch changed from $PR_HEAD_SHA to $current_head; skipping synthetic CI trigger."
482+
exit 0
483+
fi
484+
485+
git config user.name "github-actions[bot]"
486+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
487+
git commit --amend --no-edit
488+
489+
if [ -n "$API_TOKEN" ] && [ -z "$SSH_KEY" ]; then
490+
git remote set-url origin "https://x-access-token:${API_TOKEN}@github.com/${{ github.repository }}.git"
491+
fi
492+
493+
git push --force-with-lease="refs/heads/$PR_BRANCH:$PR_HEAD_SHA" origin "HEAD:refs/heads/$PR_BRANCH"

0 commit comments

Comments
 (0)