[!IMPORTANT]
pages-actionhas been deprecated with the latest release beingv1.5.0. We encourage you to migrate towrangler-action, which supports Pages deployments and offers a unified tool for managing both Workers and Pages. Here are a few important things to keep in mind as you make the migration:
- The YAML syntax for
wrangler-actionis different frompages-action. Please refer to the Pages deployment setup instructions for details.wrangler-actioncurrently does not provide the same outputs aspages-actionfor Pages project deployments. If your workflows depend on these outputs, you may need to make temporary adjustments. Rest assured, we’re working to bring these outputs towrangler-actionsoon. You can track our progress in this issue.- The "Deployment" feature available in
pages-action, which lets you view a list of past deployments, is not yet available inwrangler-action, but we plan to add this in a future release ofwrangler-action. You can track our progress in this issue.We sincerely thank you for your support and contributions to
pages-actionover the years. The repository will remain open and archived.If you have any questions or issues, please open an issue under
wrangler-actionor reach out to us directly on the Cloudflare Developers Discord.
GitHub Action for creating Cloudflare Pages deployments, using the new Direct Upload feature and Wrangler integration.
Create an API token in the Cloudflare dashboard with the "Cloudflare Pages — Edit" permission.
Add that API token as a secret to your GitHub repository, CLOUDFLARE_API_TOKEN.
Create a .github/workflows/publish.yml file in your repository:
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
# Run a build step here if your project requires
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID
projectName: YOUR_PROJECT_NAME
directory: YOUR_BUILD_OUTPUT_DIRECTORY
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional: Switch what branch you are publishing to.
# By default this will be the branch which triggered this workflow
branch: main
# Optional: Change the working directory
workingDirectory: my-site
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
wranglerVersion: '3'
Replace YOUR_ACCOUNT_ID, YOUR_PROJECT_NAME and YOUR_BUILD_OUTPUT_DIRECTORY with the appropriate values to your Pages project.
To find your account ID, log in to the Cloudflare dashboard > select your zone in Account Home > find your account ID in Overview under API on the right-side menu. If you have not added a zone, add one by selecting Add site . You can purchase a domain from Cloudflare’s registrar.
If you do not have a zone registered to your account, you can also get your account ID from the pages.dev URL. E.g: https://dash.cloudflare.com/<ACCOUNT_ID>/pages
To generate an API token:
More information can be found on our guide for making Direct Upload deployments with continous integration.
The branch name is used by Cloudflare Pages to determine if the deployment is production or preview. Read more about git branch build controls.
If you are in a Git workspace, Wrangler will automatically pull the branch information for you. You can override this
manually by adding the argument branch: YOUR_BRANCH_NAME.
By default Wrangler will run in the root package directory. If your app lives in a monorepo and you want to run Wrangler from its directory, add workingDirectory: YOUR_PACKAGE_DIRECTORY.
You can use the newly released Wrangler v3 with the wranglerVersion property.
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID
projectName: YOUR_PROJECT_NAME
directory: YOUR_BUILD_OUTPUT_DIRECTORY
# Enable Wrangler v3
wranglerVersion: '3'
| Name | Description |
|---|---|
id | The ID of the pages deployment |
url | The URL of the pages deployment |
alias | The alias if it exists otherwise the deployment URL |
environment | The environment that was deployed to |
JavaScript
99.2%
[!IMPORTANT]
pages-actionhas been deprecated with the latest release beingv1.5.0. We encourage you to migrate towrangler-action, which supports Pages deployments and offers a unified tool for managing both Workers and Pages. Here are a few important things to keep in mind as you make the migration:
- The YAML syntax for
wrangler-actionis different frompages-action. Please refer to the Pages deployment setup instructions for details.wrangler-actioncurrently does not provide the same outputs aspages-actionfor Pages project deployments. If your workflows depend on these outputs, you may need to make temporary adjustments. Rest assured, we’re working to bring these outputs towrangler-actionsoon. You can track our progress in this issue.- The "Deployment" feature available in
pages-action, which lets you view a list of past deployments, is not yet available inwrangler-action, but we plan to add this in a future release ofwrangler-action. You can track our progress in this issue.We sincerely thank you for your support and contributions to
pages-actionover the years. The repository will remain open and archived.If you have any questions or issues, please open an issue under
wrangler-actionor reach out to us directly on the Cloudflare Developers Discord.
GitHub Action for creating Cloudflare Pages deployments, using the new Direct Upload feature and Wrangler integration.
Create an API token in the Cloudflare dashboard with the "Cloudflare Pages — Edit" permission.
Add that API token as a secret to your GitHub repository, CLOUDFLARE_API_TOKEN.
Create a .github/workflows/publish.yml file in your repository:
on: [push]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
# Run a build step here if your project requires
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID
projectName: YOUR_PROJECT_NAME
directory: YOUR_BUILD_OUTPUT_DIRECTORY
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional: Switch what branch you are publishing to.
# By default this will be the branch which triggered this workflow
branch: main
# Optional: Change the working directory
workingDirectory: my-site
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
wranglerVersion: '3'
Replace YOUR_ACCOUNT_ID, YOUR_PROJECT_NAME and YOUR_BUILD_OUTPUT_DIRECTORY with the appropriate values to your Pages project.
To find your account ID, log in to the Cloudflare dashboard > select your zone in Account Home > find your account ID in Overview under API on the right-side menu. If you have not added a zone, add one by selecting Add site . You can purchase a domain from Cloudflare’s registrar.
If you do not have a zone registered to your account, you can also get your account ID from the pages.dev URL. E.g: https://dash.cloudflare.com/<ACCOUNT_ID>/pages
To generate an API token:
More information can be found on our guide for making Direct Upload deployments with continous integration.
The branch name is used by Cloudflare Pages to determine if the deployment is production or preview. Read more about git branch build controls.
If you are in a Git workspace, Wrangler will automatically pull the branch information for you. You can override this
manually by adding the argument branch: YOUR_BRANCH_NAME.
By default Wrangler will run in the root package directory. If your app lives in a monorepo and you want to run Wrangler from its directory, add workingDirectory: YOUR_PACKAGE_DIRECTORY.
You can use the newly released Wrangler v3 with the wranglerVersion property.
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID
projectName: YOUR_PROJECT_NAME
directory: YOUR_BUILD_OUTPUT_DIRECTORY
# Enable Wrangler v3
wranglerVersion: '3'
| Name | Description |
|---|---|
id | The ID of the pages deployment |
url | The URL of the pages deployment |
alias | The alias if it exists otherwise the deployment URL |
environment | The environment that was deployed to |
JavaScript
99.2%