Skip to content

Commit

Permalink
🐛 Use GH cli to merge approved PR (#1482)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Zunker <christian@mondoo.com>
  • Loading branch information
czunker authored Nov 18, 2024
1 parent 7c25daf commit 85a6470
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/pr-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,15 @@ jobs:
name: test-results
path: report.xml

go-auto-approve:
go-auto-approve-dependabot:
runs-on: ubuntu-latest
needs: [go-test, go-bench, golangci-lint, go-mod]
# For now, we auto approve and merge:
# - go dep PRs
# - cnquery update PRs
# because we have tests for this in place.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#startswith
if: |
(startsWith(github.ref, 'refs/heads/dependabot/go_modules') && github.actor == 'dependabot[bot]') ||
(startsWith(github.ref, 'refs/heads/version/cnquery_update_v') && github.event.commits[0].author.username == 'mondoo-tools')
if: startsWith(github.ref, 'refs/heads/dependabot/go_modules') && github.actor == 'dependabot[bot]'
permissions:
contents: write
pull-requests: write
Expand All @@ -115,6 +113,33 @@ jobs:
with:
pr-number: ${{ steps.pr.outputs.number }}

go-auto-approve-mondoo:
runs-on: ubuntu-latest
needs: [go-test, go-bench, golangci-lint, go-mod]
# For now, we auto approve and merge:
# - go dep PRs
# - cnquery update PRs
# because we have tests for this in place.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#startswith
if: startsWith(github.ref, 'refs/heads/version/cnquery_update_v') && github.event.commits[0].author.username == 'mondoo-tools'
permissions:
contents: write
pull-requests: write
steps:
# figure out the PR for this commit
- uses: cloudposse-github-actions/get-pr@v2.0.0
id: pr
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
filterOutClosed: true
filterOutDraft: true
- name: Approve and merge a PR
run: |
gh pr review ${{ steps.pr.outputs.number }} --approve
gh pr merge ${{ steps.pr.outputs.number }} --squash --merge
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

event_file:
name: "Store event file"
runs-on: ubuntu-latest
Expand Down

0 comments on commit 85a6470

Please sign in to comment.