Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Merge automated PRs with the automation user's token so CI runs (#82701)

Ryan Laurieecb8fe82b28a
diff --git a/.github/actions/create-backport/action.yml b/.github/actions/create-backport/action.yml
index 295c7897af0..48b524e1290 100644
--- a/.github/actions/create-backport/action.yml
+++ b/.github/actions/create-backport/action.yml
@@ -85,17 +85,27 @@ runs:
git checkout ${{ github.sha }}
- - name: Approve and Merge the PR
+ # Approving takes a different token than the one that opened the PR: GitHub won't let a token
+ # approve its own pull request.
+ - name: Approve the backport PR
if: ${{ steps.create_backport_pull_request.outputs.has-conflicts == 'false' }}
- run: |
- gh pr review --approve "$PR_NUMBER"
- gh pr merge --squash --auto "$PR_NUMBER"
+ run: gh pr review --approve "$PR_NUMBER"
shell: bash
env:
- # uses a different token than the token that created the PR so we can approve and merge it
GH_TOKEN: ${{ inputs.github-token-2 }}
PR_NUMBER: ${{ steps.create_backport_pull_request.outputs.backport_pr_number }}
+ # Merging, though, has to use `github-token` rather than the `GITHUB_TOKEN` that approves: GitHub
+ # starts no workflow run for a push made with `GITHUB_TOKEN`, so an auto-merge enabled with it
+ # lands the backport on the release branch with no CI at all.
+ - name: Merge the backport PR
+ if: ${{ steps.create_backport_pull_request.outputs.has-conflicts == 'false' }}
+ run: gh pr merge --squash --auto "$PR_NUMBER"
+ shell: bash
+ env:
+ GH_TOKEN: ${{ inputs.github-token }}
+ PR_NUMBER: ${{ steps.create_backport_pull_request.outputs.backport_pr_number }}
+
- uses: ./.github/actions/notify-pull-request
if: ${{ steps.create_backport_pull_request.outputs.has-conflicts == 'true' }}
with:
diff --git a/.github/workflows/translation-update.yml b/.github/workflows/translation-update.yml
index 147c2011006..3517d4fc74c 100644
--- a/.github/workflows/translation-update.yml
+++ b/.github/workflows/translation-update.yml
@@ -144,12 +144,20 @@ jobs:
EOF
)"
- - name: Approve and Merge the PR
- run: |
- gh pr review --approve "$PR_NUMBER"
- gh pr merge --squash --auto "$PR_NUMBER"
+ # Approving takes a different token than the one that opened the PR (above, the automation
+ # user's): GitHub won't let a token approve its own pull request.
+ - name: Approve the PR
+ run: gh pr review --approve "$PR_NUMBER"
shell: bash
env:
- # uses a different token than the token that created the PR so we can approve and merge it
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ steps.create_pr.outputs.pr_number }}
+
+ # Merging goes back through the automation user: GitHub starts no workflow run for a push made
+ # with `GITHUB_TOKEN`, so an auto-merge enabled with it lands on master with no CI.
+ - name: Merge the PR
+ run: gh pr merge --squash --auto "$PR_NUMBER"
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}
+ PR_NUMBER: ${{ steps.create_pr.outputs.pr_number }}