Skip to content

chore(deps): bump actions/checkout from 6.0.2 to 7.0.0 #3

chore(deps): bump actions/checkout from 6.0.2 to 7.0.0

chore(deps): bump actions/checkout from 6.0.2 to 7.0.0 #3

name: Dependabot auto-merge
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- ready_for_review
permissions:
contents: write
pull-requests: write
concurrency:
group: dependabot-auto-merge-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
dependabot:
name: approve and merge
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.draft == false
steps:
- name: Fetch Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify dependency update scope
env:
PACKAGE_ECOSYSTEM: ${{ steps.dependabot-metadata.outputs.package-ecosystem }}
DEPENDENCY_NAMES: ${{ steps.dependabot-metadata.outputs.dependency-names }}
UPDATED_DEPENDENCIES_JSON: ${{ steps.dependabot-metadata.outputs.updated-dependencies-json }}
run: |
set -euo pipefail
case "$PACKAGE_ECOSYSTEM" in
github-actions|npm|deno) ;;
*)
echo "::error::Unsupported Dependabot ecosystem: $PACKAGE_ECOSYSTEM"
exit 1
;;
esac
if [ -z "$DEPENDENCY_NAMES" ]; then
echo "::error::Dependabot metadata did not include dependency names."
exit 1
fi
dependency_count="$(jq 'length' <<<"$UPDATED_DEPENDENCIES_JSON")"
if [ "$dependency_count" -eq 0 ]; then
echo "::error::Dependabot metadata did not include updated dependencies."
exit 1
fi
- name: Approve Dependabot PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
set -euo pipefail
review_decision="$(gh pr view "$PR_URL" --json reviewDecision -q .reviewDecision)"
if [ "$review_decision" = "APPROVED" ]; then
echo "PR is already approved."
else
gh pr review --approve "$PR_URL"
fi
- name: Wait for checks
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
set -euo pipefail
deadline=$((SECONDS + 1800))
empty_since=""
while [ "$SECONDS" -lt "$deadline" ]; do
checks_json="$(gh pr checks "$PR_URL" --json name,bucket,workflow 2>/dev/null || true)"
relevant_checks="$(jq '[.[] | select(.workflow != "Dependabot auto-merge" and .name != "approve and merge")]' <<<"${checks_json:-[]}")"
check_count="$(jq 'length' <<<"$relevant_checks")"
failing_count="$(jq '[.[] | select(.bucket == "fail" or .bucket == "cancel")] | length' <<<"$relevant_checks")"
pending_count="$(jq '[.[] | select(.bucket == "pending")] | length' <<<"$relevant_checks")"
if [ "$failing_count" -gt 0 ]; then
echo "$relevant_checks"
echo "::error::At least one check failed or was cancelled."
exit 1
fi
if [ "$check_count" -eq 0 ]; then
if [ -z "$empty_since" ]; then
empty_since="$SECONDS"
fi
if [ $((SECONDS - empty_since)) -ge 90 ]; then
echo "No non-auto-merge checks were reported after 90 seconds."
exit 0
fi
elif [ "$pending_count" -eq 0 ]; then
echo "All reported non-auto-merge checks passed or were skipped."
exit 0
else
empty_since=""
fi
sleep 15
done
echo "::error::Timed out waiting for checks to finish."
exit 1
- name: Merge Dependabot PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr merge --squash --delete-branch "$PR_URL"