.github/workflows/slack.yml #54
This file contains hidden or 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
| on: | |
| # Run every Monday at 9:00 UTC (adjust as needed) | |
| schedule: | |
| - cron: "0 9 * * 1" | |
| jobs: | |
| send-reminder: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Retrieve open (non-draft) PRs | |
| id: open_prs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| JSON=$(gh pr list --state open --json number,title,isDraft,url) | |
| # Filter out draft pull requests | |
| FILTERED=$(echo "$JSON" | jq '[.[] | select(.isDraft == false)]') | |
| # Transform into Slack-friendly text: | |
| # e.g. "โข PR #123: My Pull Request Title (<URL>)" | |
| MESSAGE=$(echo "$FILTERED" | jq -r '.[] | "โข PR #\(.number): \(.title) (\(.url))\n"' ) | |
| # Join them into a single multiline string | |
| EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
| echo "message<<$EOF" >> $GITHUB_OUTPUT | |
| echo "Hi <!subteam^S0611DEA7ED|@marketing-squad>, there are some open pull requests requiring review. Please work with the author to get them merged or closed:\n$MESSAGE" >> $GITHUB_OUTPUT | |
| echo "$EOF" >> $GITHUB_OUTPUT | |
| - name: Post to a Slack channel | |
| uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 | |
| with: | |
| method: chat.postMessage | |
| token: ${{ secrets.SLACK_TOKEN }} | |
| payload: | | |
| channel: C04N05LJK54 | |
| text: "${{ steps.open_prs.outputs.message }}" |