forked from kamat/blog
63 lines
2.0 KiB
YAML
63 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 via eget)
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
apt-get update
|
|
apt-get install -y ca-certificates curl tar
|
|
curl -fsSL https://zyedidia.github.io/eget.sh | sh
|
|
./eget cobalt-org/cobalt.rs --to /usr/local/bin/cobalt
|
|
cobalt --version
|
|
# eget はGitHub Releasesから適切な資産を自動選択します。: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}
|