-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (44 loc) · 1.42 KB
/
slack_notifier_open_pulls.yml
File metadata and controls
52 lines (44 loc) · 1.42 KB
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
name: "post open pulls to slack"
on:
schedule:
# Run weekdays at 10:00 Eastern / 07:00 Pacific
- cron: "0 15 * * 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: >
PR_LIST=$(dev_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
uses: slackapi/slack-github-action@v2.1.1
if: ${{ env.SHOULD_POST_TO_SLACK == 'true' }}
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "${{ env.MSG }}"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.MSG }}"