Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-murakami committed Sep 1, 2023
1 parent d743756 commit a67aaa7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
24 changes: 1 addition & 23 deletions .github/workflows/dependabot-auto-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,13 @@ 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}}
18 changes: 2 additions & 16 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,9 @@ jobs:
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Check if PR is approved
id: check_approval
run: |
pr_number=${{ github.event.pull_request.number }}
repo_url="https://api.github.com/repos/${{ github.repository }}/pulls/${pr_number}/reviews" # Changed this line
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $repo_url)
if [ "$response" == "" ]; then
echo "Failed to fetch PR reviews."
exit 1
fi
approved=$(echo "$response" | jq -r 'any(.[]; .state == "APPROVED")')
echo "APPROVED=$approved" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge for Dependabot PRs
if: env.APPROVED == 'true'
if: ${{contains(steps.metadata.outputs.dependency-names, 'my-dependency') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$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 a67aaa7

Please sign in to comment.