Skip to content

Commit

Permalink
Create auto-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tosaken1116 authored Nov 5, 2023
1 parent 2f3f6b2 commit 30a0e15
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/auto-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Dependabot auto-merge
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
check_suite:
types: [completed]

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'

- name: Check if CI passed
id: ci-check
run: |
result=$(curl -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/status)
if [[ $(echo $result | jq -r '.state') != "success" ]]; then
echo "::set-output name=status::failure"
exit 1
fi
echo "::set-output name=status::success"

- name: Auto-approve
if: steps.metadata.outputs.update-type == 'version-update:semver-minor' && steps.ci-check.outputs.status == 'success'
run: |
gh pr review --approve --body "CI passed, auto-approving." ${{ github.event.pull_request.html_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-merge
if: steps.metadata.outputs.update-type == 'version-update:semver-minor' && steps.ci-check.outputs.status == 'success'
run: |
gh pr merge --auto --merge ${{ github.event.pull_request.html_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 30a0e15

Please sign in to comment.