Skip to content

Commit

Permalink
🤖 Auto approve go dep PRs by dependabot (#1346)
Browse files Browse the repository at this point in the history
* 🤖 Auto approve go dep PRs by dependabot

Signed-off-by: Christian Zunker <[email protected]>

* Move auto-approve into tests workflow

Signed-off-by: Christian Zunker <[email protected]>

---------

Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker authored Jul 15, 2024
1 parent 4ca0be1 commit 24bad2c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:

go-test:
runs-on: ubuntu-latest
id: go-test
outputs:
outcome: ${{ steps.tests.outcome }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -79,12 +82,36 @@ jobs:
run: echo $PROVIDERS_PATH

- run: make test/go/plain-ci
id: tests
- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: report.xml

go-auto-approve:
runs-on: ubuntu-latest
needs: go-test
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' && needs.go-test.outputs.outcome == 'success' }}
permissions:
contents: write
pull-requests: write
steps:
- name: Fetch PR infos
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
# For now, we only auto approve and merge go dep PRs because we have tests for this in place.
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'go' }}
# Settings the comment will auto merge the PR after all tests passed
# https://docs.github.com/en/enterprise-cloud@latest/code-security/dependabot/working-with-dependabot/managing-pull-requests-for-dependency-updates#managing-dependabot-pull-requests-with-comment-commands
run: gh pr review --comment "@dependabot squash and merge" --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

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

0 comments on commit 24bad2c

Please sign in to comment.