Files
dependabot[bot] fe26a85a6c ci(deps): bump actions/setup-node from 6 to 7
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 09:05:09 +00:00

74 lines
2.2 KiB
YAML

name: Deploy to Cloudflare Pages
on:
workflow_run:
workflows: ["Sync to Pages and Functions"]
types:
- completed
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
WRANGLER_VERSION: "4.76.0"
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
deployments: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout pages branch
uses: actions/checkout@v7
with:
ref: pages
- name: Ensure Cloudflare Pages project exists
env:
CF_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CF_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CF_PAGES_PROJECT: xget
CF_PRODUCTION_BRANCH: main
shell: bash
run: |
set -euo pipefail
api_base="https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/pages/projects"
auth_header="Authorization: Bearer ${CF_API_TOKEN}"
echo "Checking Pages project: ${CF_PAGES_PROJECT}"
if curl -fsS -H "${auth_header}" "${api_base}/${CF_PAGES_PROJECT}" >/dev/null; then
echo "Pages project exists."
exit 0
fi
echo "Pages project not found. Creating..."
create_payload="$(printf '{"name":"%s","production_branch":"%s"}' "${CF_PAGES_PROJECT}" "${CF_PRODUCTION_BRANCH}")"
curl -fsS -X POST -H "${auth_header}" -H "Content-Type: application/json" \
--data "${create_payload}" \
"${api_base}" >/dev/null
echo "Pages project created."
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "24"
- name: Install Wrangler CLI
run: npm install --global wrangler@${{ env.WRANGLER_VERSION }}
- name: Deploy to Cloudflare Pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: wrangler pages deploy . --project-name=xget --branch=${{ github.ref_name }}