Skip to content

Commit 1649038

Browse files
authored
Add slackbot to PR label workflow (aws#8665)
1 parent ea8f6bc commit 1649038

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

.github/workflows/notify-slack.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Slack Notifications
22

33
on:
4-
pull_request:
5-
types: [labeled]
64
issues:
75
types: [opened]
86

@@ -12,20 +10,8 @@ jobs:
1210
permissions:
1311
contents: read
1412
steps:
15-
- name: Wait for label to be applied
16-
run: sleep 10s
17-
shell: bash
18-
- name: Send External PR Notification
19-
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'pr/external')
20-
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2
21-
env:
22-
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
23-
SLACK_TITLE: 'PR Created: ${{ github.event.pull_request.title }} by ${{ github.event.pull_request.user.login }}'
24-
SLACK_FOOTER: ''
25-
MSG_MINIMAL: true
26-
SLACK_MESSAGE: '${{ github.event.pull_request.html_url }}'
2713
- name: Send New Issue Notification
28-
if: github.event_name == 'issue'
14+
if: github.event_name == 'issues'
2915
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2
3016
env:
3117
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/pr-labeler.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ jobs:
1919
pull-requests: write
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/github-script@v8
22+
- name: Apply internal/external label
23+
id: label_step
24+
uses: actions/github-script@v8
2325
with:
2426
github-token: ${{secrets.GITHUB_TOKEN}}
2527
script: |
@@ -29,19 +31,30 @@ jobs:
2931
'Vandita2020', 'roger-zhangg',
3032
'vicheey', 'bnusunny', 'tobixlea',
3133
'reedham-aws', 'licjun', 'dependabot[bot]'
32-
]
34+
];
3335
if (maintainers.includes(context.payload.sender.login)) {
34-
github.rest.issues.addLabels({
36+
await github.rest.issues.addLabels({
3537
issue_number: context.issue.number,
3638
owner: context.repo.owner,
3739
repo: context.repo.repo,
3840
labels: ['pr/internal']
39-
})
41+
});
42+
core.setOutput("external", "false");
4043
} else {
41-
github.rest.issues.addLabels({
44+
await github.rest.issues.addLabels({
4245
issue_number: context.issue.number,
4346
owner: context.repo.owner,
4447
repo: context.repo.repo,
4548
labels: ['pr/external', 'stage/needs-triage']
46-
})
49+
});
50+
core.setOutput("external", "true");
4751
}
52+
- name: Send Slack Notification for External PR
53+
if: steps.label_step.outputs.external == 'true'
54+
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2
55+
env:
56+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
57+
SLACK_TITLE: 'PR Created: ${{ github.event.pull_request.title }} by ${{ github.event.pull_request.user.login }}'
58+
SLACK_FOOTER: ''
59+
MSG_MINIMAL: true
60+
SLACK_MESSAGE: '${{ github.event.pull_request.html_url }}'

0 commit comments

Comments
 (0)