You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudflare-pages-action/.github/workflows/example2.yml

38 lines
1.7 KiB
YAML

on: [push,workflow_dispatch]
jobs:
example:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Example
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set production branch
run: |
result=$(curl -sS -X PATCH \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}' \
-d '{ "production_branch": "develop" }' \
https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/github-actions-example)
result=$(echo "$result" | jq -r '
if .success == true then
"Cloudflare Pages Production Branchの変更に成功しました。\n\(.result.latest_deployment.production_branch)から\(.result.production_branch)に変更されました"
else
"Cloudflare Pages Production Branchの変更に失敗しました。\nエラーコード: \(.errors[].code) \nエラーメッセージ: \(.errors[].message)"
end
')
echo "$result"
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
# Explicit branch name needed because of: https://github.com/cloudflare/pages-action/issues/97
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy example --project-name=github-actions-example --branch=develop
#command: pages deploy example --project-name=github-actions-example --branch=${{ github.head_ref || github.ref_name }}
id: publish