Skip to content

Commit

Permalink
chore: adjust readme and release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickHeneise committed Jun 23, 2024
1 parent 00d2467 commit 2dfbd33
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- run: npm test
- run: npx semantic-release
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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.
Expand Down

0 comments on commit 2dfbd33

Please sign in to comment.