Deploy on cloudflere Pages with github actions fails.

I am trying to auto deploy my project to cloudflare pages when there push in the staging branch or in production branch. below is my yml file for staging.
name: Publish Staging

on:
push:
branches:
- staging
pull_request:
types:
- synchronize

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
deployments: write

strategy:
matrix:
include:
- projectName: "portal-staging"

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- name: Setup node env 🏗
uses: actions/setup-node@v3
with:
node-version: 18.16.1
cache: "yarn"

- name: Install dependencies 👨🏻‍💻
run: yarn

- name: Run build
run: yarn portal:build

- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_STAGING_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_STAGING_ACCOUNT_ID }}
projectName: ${{ matrix.projectName }}
directory: ./apps/portal/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
name: Publish Staging

on:
push:
branches:
- staging
pull_request:
types:
- synchronize

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
deployments: write

strategy:
matrix:
include:
- projectName: "portal-staging"

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- name: Setup node env 🏗
uses: actions/setup-node@v3
with:
node-version: 18.16.1
cache: "yarn"

- name: Install dependencies 👨🏻‍💻
run: yarn

- name: Run build
run: yarn portal:build

- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_STAGING_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_STAGING_ACCOUNT_ID }}
projectName: ${{ matrix.projectName }}
directory: ./apps/portal/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
I am getting error like below when github action starts running.
Error: Failed to get Pages project, API returned non-200
at getProject (/home/runner/work/_actions/cloudflare/pages-action/1/index.js:22082:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /home/runner/work/_actions/cloudflare/pages-action/1/index.js:22167:21
Error: Failed to get Pages project, API returned non-200
at getProject (/home/runner/work/_actions/cloudflare/pages-action/1/index.js:22082:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /home/runner/work/_actions/cloudflare/pages-action/1/index.js:22167:21
1 Reply
Dj
Dj11mo ago
Bumping this a little, I had this issue as well and I set my account id to the zone id by accident :p The library makes the following call, which reading helped me find the issue!
curl -X GET "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/pages/projects/PROJECT_NAME" \
-H "Authorization: Bearer CLOUDFLARE_API_TOKEN" \
-H "Content-Type:application/json"
curl -X GET "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/pages/projects/PROJECT_NAME" \
-H "Authorization: Bearer CLOUDFLARE_API_TOKEN" \
-H "Content-Type:application/json"