Skip to content

Slack Open PRs Notification #16

Slack Open PRs Notification

Slack Open PRs Notification #16

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@ed597411d8f924073f98dfc5c65a23a2325f34cd # 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@b0fa283ad8fea605de13dc3f449259339835fc52 # v2.1.0
with:
webhook: ${{ secrets.SLACK_WEBHOOK_OSS_ALERTS }}
webhook-type: incoming-webhook
payload: |
{ "text": ${{ toJSON(format(':bar_chart: *Open PRs in {0}* ({1}): https://github.com/{0}/pulls\n{2}', github.repository, steps.open-prs.outputs.count, steps.open-prs.outputs.pr_list)) }} }