forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslack-open-prs-notification.yml
More file actions
51 lines (43 loc) · 1.56 KB
/
slack-open-prs-notification.yml
File metadata and controls
51 lines (43 loc) · 1.56 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
name: Slack Open PRs Notification
on:
schedule:
- cron: '0 13 * * *' # 8:00 AM EST (13:00 UTC)
workflow_dispatch:
permissions:
pull-requests: read
jobs:
notify-slack:
runs-on: ubuntu-latest
steps:
- name: Get open PRs
id: open-prs
uses: actions/github-script@v8
with:
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
const count = prs.length;
// Format each PR with plain text and bare URL (Slack auto-links URLs)
const prList = prs.map(pr =>
`• #${pr.number} - ${pr.title} (by ${pr.user.login})\n ${pr.html_url}`
).join('\n');
core.setOutput('count', count);
// Use GITHUB_OUTPUT delimiter for multiline support
const fs = require('fs');
fs.appendFileSync(
process.env.GITHUB_OUTPUT,
`pr_list<<PRLIST_EOF\n${prList}\nPRLIST_EOF\n`
);
- name: Send open PRs summary to Slack
uses: slackapi/slack-github-action@v3.0.1
with:
webhook: ${{ secrets.SLACK_OPEN_PRS_WEBHOOK_URL }}
webhook-type: webhook-trigger
payload: |
pr_count: "${{ steps.open-prs.outputs.count }}"
pr_list: ${{ toJSON(steps.open-prs.outputs.pr_list) }}
repository: "${{ github.repository }}"
repository_url: "https://github.com/${{ github.repository }}/pulls"