Removes the step that approved Dependabot PRs with `GITHUB_TOKEN`. Auto-merge stays enabled, so a Dependabot PR merges as soon as a person approves it and checks pass. The approval came from `GITHUB_TOKEN`, so it met the one-review rule on `main` without anyone looking at the dependency update. The org is turning off "Allow GitHub Actions to create and approve pull requests", which would make the step fail anyway. From now on Dependabot PRs need a human approval like every other PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
4.0 KiB
YAML
113 lines
4.0 KiB
YAML
name: dependabot
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
dependabot-automerge:
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
github.event_name == 'pull_request' &&
|
|
github.event.action == 'opened' &&
|
|
github.event.pull_request.user.login == 'dependabot[bot]' &&
|
|
github.event.pull_request.user.id == 49699333 &&
|
|
github.repository == 'coder/coder'
|
|
permissions:
|
|
pull-requests: write
|
|
contents: write
|
|
steps:
|
|
- name: Dependabot metadata
|
|
id: metadata
|
|
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
|
|
with:
|
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
alert-lookup: true
|
|
|
|
- name: Add backport label to security updates
|
|
id: security_backport
|
|
if: >-
|
|
${{
|
|
steps.metadata.outputs.alert-state != '' &&
|
|
!contains(github.event.pull_request.labels.*.name, 'backport')
|
|
}}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
echo "Adding backport label to security update PR $PR_URL"
|
|
gh pr edit "$PR_URL" --add-label backport
|
|
echo "added=true" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# fetch-metadata reports `github_actions`, not `github-actions`.
|
|
- name: Enable auto-merge
|
|
if: steps.metadata.outputs.package-ecosystem != 'github_actions'
|
|
run: |
|
|
echo "Enabling auto-merge for $PR_URL"
|
|
gh pr merge --auto --squash "$PR_URL"
|
|
env:
|
|
PR_URL: ${{github.event.pull_request.html_url}}
|
|
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
- name: Send Slack notification
|
|
run: |
|
|
if [ "$SECURITY_BACKPORT" = "true" ] && [ "$PACKAGE_ECOSYSTEM" = "github_actions" ]; then
|
|
STATUS_TEXT=":rotating_light: Dependabot opened security PR #${PR_NUMBER} and added the backport label (GitHub Actions changes are not auto-merged)"
|
|
elif [ "$SECURITY_BACKPORT" = "true" ]; then
|
|
STATUS_TEXT=":rotating_light: Auto merge enabled for Dependabot security PR #${PR_NUMBER}; backport label added"
|
|
elif [ "$PACKAGE_ECOSYSTEM" = "github_actions" ]; then
|
|
STATUS_TEXT=":pr-opened: Dependabot opened PR #${PR_NUMBER} (GitHub Actions changes are not auto-merged)"
|
|
else
|
|
STATUS_TEXT=":pr-merged: Auto merge enabled for Dependabot PR #${PR_NUMBER}"
|
|
fi
|
|
curl -X POST -H 'Content-type: application/json' \
|
|
--data '{
|
|
"username": "dependabot",
|
|
"icon_url": "https://avatars.githubusercontent.com/u/27347476",
|
|
"blocks": [
|
|
{
|
|
"type": "header",
|
|
"text": {
|
|
"type": "plain_text",
|
|
"text": "'"${STATUS_TEXT}"'",
|
|
"emoji": true
|
|
}
|
|
},
|
|
{
|
|
"type": "section",
|
|
"fields": [
|
|
{
|
|
"type": "mrkdwn",
|
|
"text": "'"${PR_TITLE}"'"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"type": "actions",
|
|
"elements": [
|
|
{
|
|
"type": "button",
|
|
"text": {
|
|
"type": "plain_text",
|
|
"text": "View PR"
|
|
},
|
|
"url": "'"${PR_URL}"'"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}' "${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}"
|
|
env:
|
|
SLACK_WEBHOOK: ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}
|
|
PACKAGE_ECOSYSTEM: ${{ steps.metadata.outputs.package-ecosystem }}
|
|
SECURITY_BACKPORT: ${{ steps.security_backport.outputs.added || 'false' }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_URL: ${{ github.event.pull_request.html_url }}
|