Skip to content

Commit bd2abd6

Browse files
committed
Add daily Slack notification for open PRs
1 parent 3598e43 commit bd2abd6

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Slack Open PRs Notification
2+
3+
on:
4+
schedule:
5+
- cron: '0 13 * * *' # 8:00 AM EST (13:00 UTC)
6+
workflow_dispatch:
7+
8+
permissions:
9+
pull-requests: read
10+
11+
jobs:
12+
notify-slack:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Get open PRs
16+
id: open-prs
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const { data: prs } = await github.rest.pulls.list({
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
state: 'open',
24+
});
25+
26+
const count = prs.length;
27+
28+
// Format each PR with plain text and bare URL (Slack auto-links URLs)
29+
const prList = prs.map(pr =>
30+
`• #${pr.number} - ${pr.title} (by ${pr.user.login})\n ${pr.html_url}`
31+
).join('\n');
32+
33+
core.setOutput('count', count);
34+
35+
// Use GITHUB_OUTPUT delimiter for multiline support
36+
const fs = require('fs');
37+
fs.appendFileSync(
38+
process.env.GITHUB_OUTPUT,
39+
`pr_list<<PRLIST_EOF\n${prList}\nPRLIST_EOF\n`
40+
);
41+
42+
- name: Send open PRs summary to Slack
43+
uses: slackapi/slack-github-action@v2.0.0
44+
with:
45+
webhook: ${{ secrets.SLACK_OPEN_PRS_WEBHOOK_URL }}
46+
webhook-type: webhook-trigger
47+
payload: |
48+
pr_count: "${{ steps.open-prs.outputs.count }}"
49+
pr_list: ${{ toJSON(steps.open-prs.outputs.pr_list) }}
50+
repository: "${{ github.repository }}"
51+
repository_url: "https://github.com/${{ github.repository }}/pulls"

0 commit comments

Comments
 (0)