Generate weekly PR statistics and send to Slack #1
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
| name: PR Statistics Report | |
| run-name: Generate weekly PR statistics and send to Slack | |
| on: | |
| schedule: | |
| # Every Monday at 8am GMT | |
| - cron: '0 8 * * 1' | |
| workflow_dispatch: | |
| # Allow manual triggering for testing | |
| jobs: | |
| generate-pr-statistics: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate App Token | |
| id: generate-token | |
| uses: tibdex/github-app-token@v2 | |
| with: | |
| app_id: ${{ secrets.LE_BOT_APP_ID }} | |
| private_key: ${{ secrets.LE_BOT_PRIVATE_KEY }} | |
| - name: Checkout .github repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: learningequality/.github | |
| ref: main | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Generate PR statistics | |
| id: stats | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate-token.outputs.token }} | |
| script: | | |
| const script = require('./scripts/pr-statistics.js'); | |
| return await script({github, context, core}); | |
| - name: Send Slack notification | |
| if: ${{ steps.stats.outputs.slack_message }} | |
| uses: slackapi/slack-github-action@v2.0.0 | |
| with: | |
| webhook-type: incoming-webhook | |
| webhook: ${{ secrets.SLACK_PR_STATS_WEBHOOK_URL }} | |
| payload: | | |
| { | |
| "text": ${{ toJSON(steps.stats.outputs.slack_message) }} | |
| } |