CI workflow to post open PRs to slack #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: > | |
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 | |
echo "MSG=$MSG" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_REPO: ${{ github.repository }} | |
- 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 |