-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adjust readme and release flow
- Loading branch information
1 parent
00d2467
commit 2dfbd33
Showing
2 changed files
with
25 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,40 +5,41 @@ | |
[![semantic-release: conventional](https://img.shields.io/badge/semantic--release-conventional-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
|
||
Retrieve the preview URL from the Cloudflare API, filtered by the repository and | ||
branch. The URL can then be used for further end-to-end tests, link checks and | ||
other PR integrations/actions. | ||
Retrieve the preview/deployment URL from the Cloudflare API, filtered by the | ||
repository and branch. The URL can then be used for further end-to-end tests, | ||
link checks and other PR integrations/actions. | ||
|
||
## Table of Contents | ||
## Usage | ||
|
||
- [Usage](#usage) | ||
- [Environment Variables](#environment-variables--secret) | ||
- [Inputs](#inputs) | ||
- [Outputs](#outputs) | ||
### API Token (recommended) | ||
|
||
## Usage | ||
Navigate to the | ||
[Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens) page and | ||
create a new token with the following permissions: | ||
|
||
- Account - Cloudflare Pages - Read | ||
- Include - [your page] | ||
|
||
Copy the token and add it to your repository secrets as `CLOUDFLARE_API_TOKEN`. | ||
|
||
### Global API Key | ||
|
||
[Copy your "Global API Key"](https://dash.cloudflare.com/profile/api-tokens) | ||
[Copy your "Global API Key"](https://dash.cloudflare.com/profile/api-tokens) - | ||
this also requires the Account Email to be set. | ||
|
||
Cloudflare needs a little time to build the preview, you can check the average | ||
build time in your deployments and add the seconds plus a little to a `sleep` | ||
action, to wait until the deployment is ready. The action only works on | ||
branches, so make sure you exclude the `main` branch from the trigger: | ||
### Workflow template | ||
|
||
```yaml | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
- '!main' | ||
``` | ||
Here are the steps for an example job: | ||
```yaml | ||
# Add a sleep action to wait until the deployment is ready | ||
- run: sleep 30 | ||
- name: cloudflare-preview-url | ||
uses: zentered/cloudflare-preview-url@v1 | ||
# Use the latest version | ||
uses: zentered/[email protected] | ||
id: cloudflare_preview_url | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
|
@@ -59,16 +60,16 @@ runs-on: ubuntu-latest | |
timeout-minutes: 10 | ||
``` | ||
## Environment Variables / Secret | ||
## Environment Variables / Secrets | ||
In the repository, go to "Settings", then "Secrets" and add | ||
"CLOUDFLARE_API_TOKEN", the value you can retrieve on your | ||
`CLOUDFLARE_API_TOKEN`, the value you can retrieve on your | ||
[Cloudflare account](https://dash.cloudflare.com/profile/api-tokens). You also | ||
need to add: | ||
|
||
- `CLOUDFLARE_ACCOUNT_EMAIL` (your login email, optional) | ||
- `CLOUDFLARE_ACCOUNT_ID` (from the URL: | ||
`https://dash.cloudflare.com/123abc....`) | ||
- [optional] `CLOUDFLARE_ACCOUNT_EMAIL` (your login email) | ||
|
||
When providing an account email address, the token will not be used as `Bearer` | ||
token. | ||
|