Error: Input required and not supplied: apiToken

name: Cloudflare Pages Deployment

on: [push, pull_request]

jobs:
cf:
name: Build & Deploy
runs-on: ubuntu-latest

permissions:
contents: read
deployments: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build

- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: my-project-name
directory: dist
name: Cloudflare Pages Deployment

on: [push, pull_request]

jobs:
cf:
name: Build & Deploy
runs-on: ubuntu-latest

permissions:
contents: read
deployments: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build

- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: my-project-name
directory: dist
This is the github actions workflow I'm using to deploy my react (vite) app to cf pages. It's working fine except for PRs from forks of the repo where it is giving the error (screenshot attached).
No description
10 Replies
Walshy
Walshy4mo ago
In the screenshot it isn't there My guess, the api token is not actually set. Check your secrets and re-set it
KD
KDOP4mo ago
its working for main branch push and PRs opened from branch created on the repo. its only not working for PRs from forked repos.
Walshy
Walshy4mo ago
ah except for forks yeah github doesn't let forks see secrets
Walshy
Walshy4mo ago
With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository.
KD
KDOP4mo ago
😐 any fix ? because I need preview deployments from forked repo PRs.
Walshy
Walshy4mo ago
no, you don't really want them to have access they could literally just pr a modification to the workflow with "echo $CF_API_TOKEN" and have API access to your account https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions
KD
KDOP4mo ago
ya right but I need the preview deployment so is it possibe to do so without revealing the secrect ?
Walshy
Walshy4mo ago
No that isn't how GitHub actions works You could try a different CI platform
KD
KDOP4mo ago
ok if I use git integration of CF for deployment ?
Want results from more Discord servers?
Add your server