Skip to content

CI workflow to post open PRs to slack #4

CI workflow to post open PRs to slack

CI workflow to post open PRs to slack #4

name: "post open pulls to slack"
on:
schedule:
# Run daily at 13:00 Eastern / 10:00 Pacific
- cron: "0 17 * * *"
pull_request:
branches: [main]
push:
branches: [main]
jobs:
list-open-prs:
runs-on: ubuntu-latest
permissions:
pull-requests: read
issues: read
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: List open pull requests
id: list_prs
run: >
scripts/open_pulls.sh
PR_LIST=$(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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post to Slack
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "${{ env.MSG }}"
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.MSG }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK