forked from kamat/blog
61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
name: Deploy to Cloudflare Pages (cobalt)
|
||
|
||
on:
|
||
push:
|
||
branches: ["main", "master"]
|
||
workflow_dispatch: {}
|
||
|
||
jobs:
|
||
build-and-deploy:
|
||
runs-on: ubuntu-latest
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: https://github.com/actions/checkout@v4
|
||
# Giteaは絶対URLでの外部Action取得に対応。:contentReference[oaicite:6]{index=6}
|
||
|
||
- name: Setup Node for Wrangler
|
||
uses: https://github.com/actions/setup-node@v4
|
||
with:
|
||
node-version: "20"
|
||
|
||
- name: Install cobalt (prebuilt release)
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
curl -LSfs https://raw.githubusercontent.com/crate-ci/gh-install/master/v1/install.sh \
|
||
| sh -s -- --git cobalt-org/cobalt.rs --crate cobalt
|
||
~/.cargo/bin/cobalt --version # 動作確認
|
||
# 公式ドキュメントの「Pre-built Binary」を使用(rustc不要)。:contentReference[oaicite:1]{index=1}
|
||
|
||
- name: Build site with cobalt
|
||
run: cobalt build
|
||
# 既定の出力は ./_site。:contentReference[oaicite:8]{index=8}
|
||
|
||
- name: Install Wrangler
|
||
run: npm i -g wrangler@latest
|
||
|
||
- name: Compute BRANCH_NAME
|
||
id: branch
|
||
shell: bash
|
||
run: |
|
||
bn="${GITHUB_REF_NAME:-${GITEA_REF_NAME:-}}"
|
||
if [ -z "$bn" ] && [ -n "${GITHUB_REF:-${GITEA_REF:-}}" ]; then
|
||
ref="${GITHUB_REF:-${GITEA_REF}}"
|
||
bn="${ref##*/}"
|
||
fi
|
||
echo "BRANCH_NAME=$bn" >> "$GITHUB_ENV"
|
||
|
||
- name: Deploy to Cloudflare Pages
|
||
env:
|
||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||
CF_PAGES_PROJECT: ${{ vars.CF_PAGES_PROJECT }}
|
||
run: |
|
||
test -n "$CF_PAGES_PROJECT"
|
||
npx wrangler pages deploy "_site" \
|
||
--project-name "$CF_PAGES_PROJECT" \
|
||
--account-id "$CLOUDFLARE_ACCOUNT_ID" \
|
||
--branch "$BRANCH_NAME"
|
||
# CIでのwrangler deploy手順に準拠。:contentReference[oaicite:9]{index=9}
|