Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-murakami committed Aug 31, 2023
1 parent e20440e commit 6cbdc48
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/dependabot-auto-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,35 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Check all CI jobs
id: check
run: |
commit_sha=$(git rev-parse HEAD)
repo_url="https://api.github.com/repos/${{ github.repository }}"
checks_url="${repo_url}/commits/${commit_sha}/check-runs"
# Fetch all check runs for the commit
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" $checks_url)
# Check if all check runs have completed and succeeded
all_passed=$(echo "$response" | jq -r 'all(.check_runs[] | select(.status == "completed") .conclusion == "success")')
if [ "$all_passed" == "true" ]; then
echo "ALL_CHECKS_PASSED=true" >> $GITHUB_ENV
else
echo "Not all checks have passed."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dependabot metadata
if: env.ALL_CHECKS_PASSED == 'true'
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
if: env.ALL_CHECKS_PASSED == 'true'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 6cbdc48

Please sign in to comment.