-
Notifications
You must be signed in to change notification settings - Fork 887
chore: auto merge dependabot PRs for patch updates #16222
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: contrib | |
on: | ||
issue_comment: | ||
types: [created] | ||
pull_request_target: | ||
pull_request: | ||
types: | ||
- opened | ||
- closed | ||
|
@@ -24,33 +24,38 @@ concurrency: pr-${{ github.ref }} | |
|
||
jobs: | ||
# Dependabot is annoying, but this makes it a bit less so. | ||
auto-approve-dependabot: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request_target' | ||
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder' | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d # v2.2.0 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: auto-approve dependabot | ||
uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 | ||
if: github.actor == 'dependabot[bot]' | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Approve the PR | ||
run: gh pr review --approve "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Enable auto-merge for Dependabot PRs | ||
if: 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}} | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
cla: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | ||
with: | ||
egress-policy: audit | ||
|
||
Comment on lines
-47
to
-51
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. Removing these as they do not provide any value in this workflow. |
||
- name: cla | ||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' | ||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request' | ||
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -69,13 +74,8 @@ jobs: | |
release-labels: | ||
runs-on: ubuntu-latest | ||
# Skip tagging for draft PRs. | ||
if: ${{ github.event_name == 'pull_request_target' && !github.event.pull_request.draft }} | ||
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }} | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: release-labels | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This seems far too flimsy; is there no way we can reference a user by ID?
This workflow has to be crazy hardened if we're going to enable it.
See also: https://www.synacktiv.com/en/publications/github-actions-exploitation-dependabot
I have not read it fully; I'm focused on other tasks today
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.
We have been doing it at other places in
ci.yaml
too.Also, they suggest we follow the GitHub docs. See: https://www.synacktiv.com/en/publications/github-actions-exploitation-dependabot#footnote4_i8j88po
And we are exactly following that.
As far as I understand, the exploit only works when using
pull_request_target,
and I have changed that topull_request
as per GitHub's recommendation.See: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
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.
Also trpc fixed it by updating
github.actor
-->github.event.pull_request.user.login
See: trpc/trpc@8187594
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.
https://api.github.com/users/dependabot[bot]
Can we not reference the ID instead? I wonder why they suggest
login
instead; feels flimsy.