-
Notifications
You must be signed in to change notification settings - Fork 904
ci: fix cla and dependabot notifications jobs #16343
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
5 commits
Select commit
Hold shift + click to select a range
cfb86ab
ci: fix cla and dependabot notifications
matifali 26e9fac
extract dependabot logic to dependabot.yaml
matifali 2b057b5
remove dependabot logic
matifali 2305d58
Remove comment from pull_request_target section
matifali ed7875d
Update GitHub Actions PR validation logic
matifali 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 |
---|---|---|
|
@@ -2,15 +2,14 @@ name: contrib | |
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
pull_request: | ||
types: [created, edited] | ||
pull_request_target: | ||
types: | ||
- opened | ||
- closed | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
- opened | ||
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. removed the duplicate from L8 |
||
- reopened | ||
- edited | ||
# For jobs that don't run on draft PRs. | ||
|
@@ -23,88 +22,13 @@ permissions: | |
concurrency: pr-${{ github.ref }} | ||
|
||
jobs: | ||
# Dependabot is annoying, but this makes it a bit less so. | ||
dependabot-automerge: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder' | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0 | ||
with: | ||
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 | ||
run: gh pr merge --auto --squash "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
dependabot-automerge-notify: | ||
# Send a slack notification when a dependabot PR is merged. | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder' && github.event.pull_request.merged | ||
steps: | ||
- name: Send Slack notification | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
PR_TITLE: ${{github.event.pull_request.title}} | ||
PR_NUMBER: ${{github.event.pull_request.number}} | ||
run: | | ||
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": ":pr-merged: Auto merged Dependabot PR #${{ env.PR_NUMBER }}", | ||
"emoji": true | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "${{ env.PR_TITLE }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View PR" | ||
}, | ||
"url": "${{ env.PR_URL }}" | ||
} | ||
] | ||
} | ||
] | ||
}' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }} | ||
|
||
cla: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- 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' | ||
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' | ||
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -123,7 +47,7 @@ jobs: | |
release-labels: | ||
runs-on: ubuntu-latest | ||
# Skip tagging for draft PRs. | ||
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }} | ||
if: ${{ github.event_name == 'pull_request_target' && !github.event.pull_request.draft }} | ||
steps: | ||
- name: release-labels | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
|
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: dependabot | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
# Only run one instance per PR to ensure in-order execution. | ||
concurrency: pr-${{ github.ref }} | ||
|
||
jobs: | ||
# Dependabot is annoying, but this makes it a bit less so. | ||
dependabot-automerge: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.actor_id == 49699333 && github.repository == 'coder/coder' | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
matifali marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Approve the PR | ||
run: | | ||
echo "Approving $PR_URL" | ||
gh pr review --approve "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Enable auto-merge | ||
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}} | ||
|
||
dependabot-automerge-notify: | ||
# Send a slack notification when a dependabot PR is merged. | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && github.actor == 'github-actions[bot]' && github.actor_id == 41898282 && github.repository == 'coder/coder' | ||
steps: | ||
- name: Send Slack notification | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
PR_TITLE: ${{github.event.pull_request.title}} | ||
PR_NUMBER: ${{github.event.pull_request.number}} | ||
run: | | ||
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": ":pr-merged: Auto merged Dependabot PR #${{ env.PR_NUMBER }}", | ||
"emoji": true | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "${{ env.PR_TITLE }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View PR" | ||
}, | ||
"url": "${{ env.PR_URL }}" | ||
} | ||
] | ||
} | ||
] | ||
}' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }} |
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.
Uh oh!
There was an error while loading. Please reload this page.