File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments