ワンライ更新 #10
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: Theme update announcement | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "src/data/onehourwriting/themes.json" | |
| workflow_dispatch: | |
| jobs: | |
| discord-announcement: | |
| name: Discord Announcement | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Read JSON file and Call Webhook | |
| id: get-themes | |
| env: | |
| WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL_FOR_THEME_UPDATE }} | |
| run: | | |
| # JSONファイルを読み取って内容を変数に格納 | |
| json_data=$(cat ./src/data/onehourwriting/themes.json | jq '.themes') | |
| t1=$(echo $json_data | jq -r '.[0]') | |
| t2=$(echo $json_data | jq -r '.[1]') | |
| t3=$(echo $json_data | jq -r '.[2]') | |
| # メッセージを作成 | |
| message="テーマが更新されました。\n次回のテーマは「${t1}」、「${t2}」、「${t3}」です。" | |
| # Webhookに送信するペイロードを作成 | |
| payload="{\"content\": \"$message\"}" | |
| # WebhookにPOSTリクエストを送信 | |
| curl -X POST "$WEBHOOK_URL" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$payload" | |