Notify chapter count #27
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: Notify chapter count | |
on: | |
schedule: | |
- cron: '0 9 * * *' | |
workflow_dispatch: | |
jobs: | |
check-env: | |
runs-on: ubuntu-latest | |
outputs: | |
slack_webhook_set: ${{ steps.check-slack-webhook.outputs.slack_webhook_set }} | |
steps: | |
- name: Check SLACK_WEBHOOK_URL | |
id: check-slack-webhook | |
run: | | |
if [ -z "${{ secrets.SLACK_WEBHOOK_URL }}" ]; then | |
echo "SLACK_WEBHOOK_URL is not set. Skipping the job." | |
echo "slack_webhook_set=false" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "slack_webhook_set=true" >> $GITHUB_OUTPUT | |
fi | |
check-and-notify: | |
runs-on: ubuntu-latest | |
needs: check-env | |
if: needs.check-env.outputs.slack_webhook_set == 'true' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: 'Setup Deno' | |
uses: denoland/setup-deno@v2 | |
with: | |
deno-version: v2.x | |
# 前回のデータをキャッシュから復元 | |
- name: Restore cache | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: stats_cache.json | |
key: daily_stats | |
- name: Initialize stats_cache.json if not restored | |
run: | | |
if [ ! -f stats_cache.json ]; then | |
echo '{"chapterCount": 0}' > stats_cache.json | |
fi | |
- name: Compare and Notify with Deno | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
run: | | |
deno run --allow-read --allow-write --allow-env --allow-net .github/scripts/stats.ts \ | |
stats_cache.json src/catalog.yml |