generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (53 loc) · 1.59 KB
/
slack_notifier_open_pulls.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: "post open pulls to slack"
on:
schedule:
# Run weekdays at 13:00 Eastern / 10:00 Pacific
- cron: "0 17 * * 1-5"
jobs:
list-open-prs:
runs-on: ubuntu-latest
permissions:
pull-requests: read
issues: read
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: List open pull requests
id: list_prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: >
PR_LIST=$(scripts/open_pulls.sh)
MSG=":code-review: Open Pull Requests\n\n"
while IFS= read -r line; do
MSG+="$line\n"
done < <(echo "$PR_LIST" | jq -r '.[] | " - <\(.html_url)|\(.title)> opened by \(.user) \(.time_since) days ago"')
echo "MSG=$MSG" >> $GITHUB_ENV
# Check if PR_LIST is empty and set a flag
if [ "$PR_LIST" == "[]" ]; then
echo "SHOULD_POST_TO_SLACK=false" >> $GITHUB_ENV
else
echo "SHOULD_POST_TO_SLACK=true" >> $GITHUB_ENV
fi
- name: Post to Slack
id: slack
uses: slackapi/[email protected]
if: ${{ env.SHOULD_POST_TO_SLACK == 'true' }}
with:
payload: |
{
"text": "${{ env.MSG }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.MSG }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK