Skip to content

Crosspost to dev.to #36

Crosspost to dev.to

Crosspost to dev.to #36

name: Crosspost to dev.to
# Zenn の英語自動翻訳が付いた記事を dev.to へ転載する。
# Zenn の翻訳は日本語公開から数日後に非同期で進むため、push ではなく
# 毎日のポーリングで「翻訳済みか」を確認する。
on:
schedule:
- cron: "0 0 * * *" # 毎日 00:00 UTC = 09:00 JST
workflow_dispatch: # 手動実行用
permissions:
contents: write # crossposted-devto.json のコミットに必要
concurrency:
group: crosspost-devto
cancel-in-progress: false
jobs:
crosspost:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: "20"
- name: Install dependencies
run: npm ci
working-directory: .github/scripts
- name: Test and validate local sources
run: |
npm --prefix .github/scripts test
node tools/validate-content.mjs
node tools/zenn-sync/sync.mjs --check
- name: Prepare reservation or recover previous posting
id: prepare
run: node .github/scripts/crosspost-devto.mjs --prepare
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
- name: Persist reservation before external POST
run: |
if [ -n "$(git status --porcelain crossposted-devto.json)" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add crossposted-devto.json
git commit -m "chore: reserve dev.to crosspost"
git push
else
echo "No state change."
fi
- name: Send newly reserved article
if: steps.prepare.outputs.created == 'true'
run: node .github/scripts/crosspost-devto.mjs --send-new
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
- name: Fix one resolvable internal link set
run: node .github/scripts/crosspost-devto.mjs --fix-links
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
- name: Persist finalized crosspost state
run: |
if [ -n "$(git status --porcelain crossposted-devto.json)" ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add crossposted-devto.json
git commit -m "chore: finalize dev.to crosspost state"
git push
else
echo "No state change."
fi