forked from kamat/blog
66 lines
2.2 KiB
YAML
66 lines
2.2 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)
|
||
shell: bash
|
||
run: |
|
||
if ! command -v curl >/dev/null 2>&1; then
|
||
(apt-get update && apt-get install -y curl) \
|
||
|| (apk add --no-cache curl) \
|
||
|| (dnf -y install curl) \
|
||
|| (pacman -Sy --noconfirm curl)
|
||
fi
|
||
curl -LSfs https://raw.githubusercontent.com/crate-ci/gh-install/master/v1/install.sh \
|
||
| sh -s -- --git cobalt-org/cobalt.rs --crate cobalt
|
||
cobalt --version
|
||
# cobaltのインストール手順(prebuilt)。:contentReference[oaicite:7]{index=7}
|
||
|
||
- 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}
|