Monthly Traffic Report #18
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: Monthly Traffic Report | |
| on: | |
| schedule: | |
| - cron: '0 14 28-31 * *' | |
| workflow_dispatch: | |
| inputs: | |
| test_mode: | |
| description: 'Skip posting to Slack and print payload to logs instead' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| report: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if today is the last day of the month | |
| if: github.event_name != 'workflow_dispatch' | |
| id: check-date | |
| run: | | |
| TODAY=$(date +%d) | |
| LAST=$(date -d "$(date +%Y-%m-01) +1 month -1 day" +%d) | |
| if [ "$TODAY" != "$LAST" ]; then | |
| echo "Not the last day of the month. Exiting early." | |
| echo "is_last_day=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "is_last_day=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout repository | |
| if: github.event_name == 'workflow_dispatch' || steps.check-date.outputs.is_last_day == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| if: github.event_name == 'workflow_dispatch' || steps.check-date.outputs.is_last_day == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Aggregate monthly metrics and post to Slack | |
| if: github.event_name == 'workflow_dispatch' || steps.check-date.outputs.is_last_day == 'true' | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| GITHUB_TOKEN: ${{ secrets.TRAFFIC_PAT }} | |
| TEST_MODE: ${{ inputs.test_mode || 'false' }} | |
| run: node .github/scripts/aggregate-monthly.js |