Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e37b7fc

Browse files
authored
ci: fix cla and dependabot notifications jobs (#16343)
1 parent 2ace044 commit e37b7fc

File tree

2 files changed

+99
-80
lines changed

2 files changed

+99
-80
lines changed

.github/workflows/contrib.yaml

+4-80
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ name: contrib
22

33
on:
44
issue_comment:
5-
types: [created]
6-
pull_request:
5+
types: [created, edited]
6+
pull_request_target:
77
types:
88
- opened
99
- closed
1010
- synchronize
1111
- labeled
1212
- unlabeled
13-
- opened
1413
- reopened
1514
- edited
1615
# For jobs that don't run on draft PRs.
@@ -23,88 +22,13 @@ permissions:
2322
concurrency: pr-${{ github.ref }}
2423

2524
jobs:
26-
# Dependabot is annoying, but this makes it a bit less so.
27-
dependabot-automerge:
28-
runs-on: ubuntu-latest
29-
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder'
30-
permissions:
31-
pull-requests: write
32-
contents: write
33-
steps:
34-
- name: Dependabot metadata
35-
id: metadata
36-
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
37-
with:
38-
github-token: "${{ secrets.GITHUB_TOKEN }}"
39-
40-
- name: Approve the PR
41-
run: gh pr review --approve "$PR_URL"
42-
env:
43-
PR_URL: ${{github.event.pull_request.html_url}}
44-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
45-
46-
- name: Enable auto-merge for Dependabot PRs
47-
run: gh pr merge --auto --squash "$PR_URL"
48-
env:
49-
PR_URL: ${{github.event.pull_request.html_url}}
50-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
51-
52-
dependabot-automerge-notify:
53-
# Send a slack notification when a dependabot PR is merged.
54-
runs-on: ubuntu-latest
55-
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'coder/coder' && github.event.pull_request.merged
56-
steps:
57-
- name: Send Slack notification
58-
env:
59-
PR_URL: ${{github.event.pull_request.html_url}}
60-
PR_TITLE: ${{github.event.pull_request.title}}
61-
PR_NUMBER: ${{github.event.pull_request.number}}
62-
run: |
63-
curl -X POST -H 'Content-type: application/json' \
64-
--data '{
65-
"username": "dependabot",
66-
"icon_url": "https://avatars.githubusercontent.com/u/27347476",
67-
"blocks": [
68-
{
69-
"type": "header",
70-
"text": {
71-
"type": "plain_text",
72-
"text": ":pr-merged: Auto merged Dependabot PR #${{ env.PR_NUMBER }}",
73-
"emoji": true
74-
}
75-
},
76-
{
77-
"type": "section",
78-
"fields": [
79-
{
80-
"type": "mrkdwn",
81-
"text": "${{ env.PR_TITLE }}"
82-
}
83-
]
84-
},
85-
{
86-
"type": "actions",
87-
"elements": [
88-
{
89-
"type": "button",
90-
"text": {
91-
"type": "plain_text",
92-
"text": "View PR"
93-
},
94-
"url": "${{ env.PR_URL }}"
95-
}
96-
]
97-
}
98-
]
99-
}' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}
100-
10125
cla:
10226
runs-on: ubuntu-latest
10327
permissions:
10428
pull-requests: write
10529
steps:
10630
- name: cla
107-
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'
31+
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'
10832
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
10933
env:
11034
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -123,7 +47,7 @@ jobs:
12347
release-labels:
12448
runs-on: ubuntu-latest
12549
# Skip tagging for draft PRs.
126-
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
50+
if: ${{ github.event_name == 'pull_request_target' && !github.event.pull_request.draft }}
12751
steps:
12852
- name: release-labels
12953
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1

.github/workflows/dependabot.yaml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: dependabot
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
# Only run one instance per PR to ensure in-order execution.
15+
concurrency: pr-${{ github.ref }}
16+
17+
jobs:
18+
# Dependabot is annoying, but this makes it a bit less so.
19+
dependabot-automerge:
20+
runs-on: ubuntu-latest
21+
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.actor_id == 49699333 && github.repository == 'coder/coder'
22+
permissions:
23+
pull-requests: write
24+
contents: write
25+
steps:
26+
- name: Dependabot metadata
27+
id: metadata
28+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
29+
with:
30+
github-token: "${{ secrets.GITHUB_TOKEN }}"
31+
32+
- name: Approve the PR
33+
run: |
34+
echo "Approving $PR_URL"
35+
gh pr review --approve "$PR_URL"
36+
env:
37+
PR_URL: ${{github.event.pull_request.html_url}}
38+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
39+
40+
- name: Enable auto-merge
41+
run: |
42+
echo "Enabling auto-merge for $PR_URL"
43+
gh pr merge --auto --squash "$PR_URL"
44+
env:
45+
PR_URL: ${{github.event.pull_request.html_url}}
46+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
47+
48+
dependabot-automerge-notify:
49+
# Send a slack notification when a dependabot PR is merged.
50+
runs-on: ubuntu-latest
51+
if: github.event_name == 'push' && github.actor == 'github-actions[bot]' && github.actor_id == 41898282 && github.repository == 'coder/coder'
52+
steps:
53+
- name: Send Slack notification
54+
env:
55+
PR_URL: ${{github.event.pull_request.html_url}}
56+
PR_TITLE: ${{github.event.pull_request.title}}
57+
PR_NUMBER: ${{github.event.pull_request.number}}
58+
run: |
59+
curl -X POST -H 'Content-type: application/json' \
60+
--data '{
61+
"username": "dependabot",
62+
"icon_url": "https://avatars.githubusercontent.com/u/27347476",
63+
"blocks": [
64+
{
65+
"type": "header",
66+
"text": {
67+
"type": "plain_text",
68+
"text": ":pr-merged: Auto merged Dependabot PR #${{ env.PR_NUMBER }}",
69+
"emoji": true
70+
}
71+
},
72+
{
73+
"type": "section",
74+
"fields": [
75+
{
76+
"type": "mrkdwn",
77+
"text": "${{ env.PR_TITLE }}"
78+
}
79+
]
80+
},
81+
{
82+
"type": "actions",
83+
"elements": [
84+
{
85+
"type": "button",
86+
"text": {
87+
"type": "plain_text",
88+
"text": "View PR"
89+
},
90+
"url": "${{ env.PR_URL }}"
91+
}
92+
]
93+
}
94+
]
95+
}' ${{ secrets.DEPENDABOT_PRS_SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)