update #40
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: update | |
on: | |
workflow_dispatch: | |
schedule: | |
# 日本時間 毎月1日 午前9時 | |
- cron: "0 0 1 * *" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- name: Fetch New Artwork Data | |
run: deno task update | |
env: | |
MONGO_DB_URL: ${{ secrets.MONGO_DB_URL }} | |
MONGO_DB_NAME: ${{ secrets.MONGO_DB_NAME }} | |
- name: Process data to send to Slack | |
if: hashFiles('data.json') != '' | |
id: process | |
run: | | |
titles=$(cat data.json | jq -r '.[].title' | sed 's/^/- /') | |
titles=${titles//$'\n'/\\n} | |
echo "::set-output name=titles::$titles" | |
- name: Send to Slack | |
if: hashFiles('data.json') != '' | |
uses: slackapi/[email protected] | |
with: | |
channel-id: 'C03JQ4MPLMN' | |
payload: | | |
{ | |
"text": "DBを更新しました", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "DBを更新しました\n```\n${{ steps.process.outputs.titles }}\n```" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
- name: Upload to DB | |
if: hashFiles('data.json') != '' | |
run: deno task upload | |
env: | |
MONGO_DB_URL: ${{ secrets.MONGO_DB_URL }} | |
MONGO_DB_NAME: ${{ secrets.MONGO_DB_NAME }} |