-
-
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.
feat: add GitHub Actions workflow for automatic merging of Dependabot…
… PRs based on compatibility score
- Loading branch information
1 parent
17e49aa
commit 6d2ffc0
Showing
1 changed file
with
62 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Auto Merge Depandabot PRs | ||
|
||
on: | ||
pull_request: | ||
types: [opened, labeled] | ||
branches: [master, main] | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
attestations: write | ||
security-events: write | ||
pull-requests: write | ||
|
||
jobs: | ||
auto_merge_depandabot_pr: | ||
name: Auto Merge Depandabot PR | ||
runs-on: ubuntu-latest | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'dependencies') && contains(github.event.pull_request.labels.*.name, 'github-actions') }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Extract Badge URL | ||
id: extract_url | ||
run: | | ||
pr_body="${{ github.event.pull_request.body }}" | ||
badge_url=$(echo "$pr_body" | grep -oP '(?<=\[!\[Dependabot compatibility score]\().+?(?=\))') | ||
echo "badge_url=$badge_url" >> $GITHUB_ENV | ||
- name: Download and Parse SVG | ||
id: parse_svg | ||
run: | | ||
echo "Downloading SVG from: ${{ env.badge_url }}" | ||
svg_content=$(curl -s "${{ env.badge_url }}") | ||
compatibility_score=$(echo "$svg_content" | grep -oP '(?<=<title>compatibility: )\d+(?=%</title>)') | ||
echo "compatibility_score=$compatibility_score" >> $GITHUB_ENV | ||
- name: Validate Compatibility Score | ||
id: validate_score | ||
run: | | ||
if [[ "${{ env.compatibility_score }}" -ge 70 ]]; then | ||
echo "Score is sufficient: ${{ env.compatibility_score }}%" | ||
echo "should_merge=true" >> $GITHUB_ENV | ||
else | ||
echo "Score is too low: ${{ env.compatibility_score }}%" | ||
echo "should_merge=false" >> $GITHUB_ENV | ||
fi | ||
- name: Attest Build Provenance | ||
if: ${{ env.should_merge == 'true' }} | ||
uses: actions/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
subject-name: "Auto Merge Depandabot PR" | ||
subject-path: ".github/workflows/auto_merge_depandabot.yml" | ||
|
||
- name: Merge PR | ||
uses: peter-evans/enable-pull-request-automerge@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
pull-request-number: ${{ github.event.pull_request.number }} | ||
merge-method: squash |