-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(automerge): Update and improve auto-merge PR
* Improved both auto approve and merge jobs * Changed the committer to author instead github-action[bot] * Now the workflow will only run if check suite has completed Signed-off-by: Ryuu Mitsuki <dhefam31@gmail.com>
- Loading branch information
Showing
1 changed file
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,55 @@ | ||
name: Dependabot Auto-merge | ||
name: Auto-merge Dependabot PR | ||
on: | ||
pull_request: | ||
|
||
# Required to edit pull requests | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
check_suite: | ||
types: [ completed ] | ||
|
||
jobs: | ||
build: | ||
autoapprove: | ||
runs-on: ubuntu-latest | ||
if: github.actor == 'dependabot[bot]' # Only if the actor is Dependabot | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Dependabot metadata | ||
- name: Approve PR | ||
uses: hmarr/auto-approve-action@v4 | ||
with: | ||
github-token: ${{ secrets.M31_PAT }} | ||
review-message: 'Auto approved PR' | ||
|
||
automerge: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} # Only if the actor is Dependabot | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Fetch Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@v2 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Auto-merge Dependabot PR | ||
- name: Merge PR | ||
# Auto-merge all Dependabot PRs with patch updates | ||
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' | ||
# Approve and merge the PR | ||
run: | | ||
gh pr review --approve "$PR_URL" | ||
gh pr comment --body "@dependabot merge" | ||
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }} | ||
id: merge_pr | ||
needs: metadata | ||
uses: pascalgn/automerge-action@v0.16.3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.M31_PAT }} | ||
MERGE_METHOD: merge | ||
MERGE_COMMIT_MESSAGE: 'pull-request-title' | ||
|
||
- name: Post-merge PR | ||
needs: merge_pr | ||
if: ${{ steps.automerge.outputs.mergeResult == 'merged' }} | ||
run: > | ||
gh pr comment --body 'Auto merged PR' | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.M31_PAT }} |