diff --git a/CHANGELOG.md b/CHANGELOG.md index 8140d27..e04d384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixes +- Updater - Trigger CI for new PRs without changelog updates ([#166](https://github.com/getsentry/github-workflows/pull/166)) - Updater - Select the first branch when multiple branches point at `HEAD` ([#165](https://github.com/getsentry/github-workflows/pull/165)) ### Dependencies diff --git a/updater/action.yml b/updater/action.yml index b993ca2..e38c2c0 100644 --- a/updater/action.yml +++ b/updater/action.yml @@ -462,3 +462,32 @@ runs: Auto-generated by a [dependency updater](https://github.com/getsentry/github-workflows/blob/main/updater/action.yml). ${{ env.TARGET_CHANGELOG }} labels: dependencies + + - name: Trigger PR workflows + 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 ) }} + shell: bash + working-directory: caller-repo + env: + PR_BRANCH: ${{ steps.root.outputs.prBranch }} + PR_HEAD_SHA: ${{ steps.create-pr.outputs.pull-request-head-sha }} + API_TOKEN: ${{ inputs.api-token }} + SSH_KEY: ${{ inputs.ssh-key }} + run: | + git fetch origin "$PR_BRANCH" + git checkout --force -B "$PR_BRANCH" "origin/$PR_BRANCH" + + current_head=$(git rev-parse HEAD) + if [ "$current_head" != "$PR_HEAD_SHA" ]; then + echo "::notice::PR branch changed from $PR_HEAD_SHA to $current_head; skipping synthetic CI trigger." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit --amend --no-edit + + if [ -n "$API_TOKEN" ] && [ -z "$SSH_KEY" ]; then + git remote set-url origin "https://x-access-token:${API_TOKEN}@github.com/${{ github.repository }}.git" + fi + + git push --force-with-lease="refs/heads/$PR_BRANCH:$PR_HEAD_SHA" origin "HEAD:refs/heads/$PR_BRANCH"