-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ci): add Dependabot + safe automerge for GitHub Actions #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| groups: | ||
| github-actions: | ||
| patterns: | ||
| - "*" | ||
| commit-message: | ||
| prefix: ci |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Automerge | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| dependabot: | ||
| if: github.actor == 'dependabot[bot]' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Fetch Dependabot metadata | ||
| id: metadata | ||
| uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Approve and enable auto-merge (patch/minor only) | ||
| if: steps.metadata.outputs.update-type != 'version-update:semver-major' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| run: | | ||
| gh pr review "$PR_URL" --approve | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛑 Logic Error: The workflow will fail when attempting to auto-approve Dependabot PRs. GitHub Actions does not allow a workflow run triggered by Add a dedicated bot token with PR approval permissions to Footnotes
|
||
| gh pr merge "$PR_URL" --squash --auto | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛑 Security Vulnerability: Using
pull_request_targetwith write permissions creates a privilege escalation risk. This trigger runs workflows in the context of the base repository with access to secrets, even for PRs from forks. While theif: github.actor == 'dependabot[bot]'check provides some mitigation, a compromised Dependabot action or a race condition could still allow malicious code execution with write access to the repository.1Switch to the
pull_requesttrigger instead. The workflow will still have access toGITHUB_TOKENwith sufficient permissions for Dependabot PRs since Dependabot PRs originate from the same repository, not external forks.Footnotes
CWE-669: Incorrect Resource Transfer Between Spheres - https://cwe.mitre.org/data/definitions/669.html ↩