Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f62debcf8 | |||
| 006366c1ae | |||
| 95ac136231 | |||
| a33b48c9fe | |||
| 60c377d0bf | |||
| 39c3d279a1 | |||
| 8df5ab90b3 | |||
| f4e53e2753 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM node:12
|
||||
FROM node:16
|
||||
ENV XDG_CONFIG_HOME /github/workspace
|
||||
ENV WRANGLER_HOME /github/workspace
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiKey: ${{ secrets.CF_API_KEY }}
|
||||
email: ${{ secrets.CF_EMAIL }}
|
||||
@@ -63,7 +63,7 @@ If you're using Wrangler's [environments](https://developers.cloudflare.com/work
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
environment: 'production'
|
||||
@@ -75,7 +75,7 @@ If you need to install a specific version of Wrangler to use for deployment, you
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
wranglerVersion: '1.6.0'
|
||||
@@ -87,7 +87,7 @@ Optionally, you can also pass a `workingDirectory` key to the action. This will
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
workingDirectory: 'subfoldername'
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
secrets: |
|
||||
@@ -116,7 +116,7 @@ If you need to run additional shell commands before or after `wrangler publish`,
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
preCommands: echo "*** pre command ***"
|
||||
@@ -132,7 +132,7 @@ Set the optional `publish` input to false to skip publishing your Worker project
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
publish: false
|
||||
@@ -158,7 +158,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish app
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -190,12 +190,16 @@ If you need help defining the correct cron syntax, check out [crontab.guru](http
|
||||
|
||||
### Deploying on a "dispatched" event
|
||||
|
||||
If you need to trigger a deployment at-will, you can use GitHub's API to fire a `repository_dispatch` event on your repository. By setting your workflow to trigger on that event, you'll be able to deploy your application via an API call:
|
||||
If you need to trigger a workflow at-will, you can use GitHub's `workflow_dispatch` [event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch) in your workflow file. By setting your workflow to trigger on that event, you'll be able to deploy your application via the GitHub UI. The UI also accepts inputs that can be used to configure the action :
|
||||
|
||||
```yaml
|
||||
on:
|
||||
repository_dispatch:
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'Choose an environment to deploy to: <dev|staging|prod>'
|
||||
required: true
|
||||
default: 'dev'
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -203,32 +207,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish app
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
environment: ${{ github.event.inputs.environment }}
|
||||
```
|
||||
|
||||
To make the GitHub API request, you can deploy a custom [Cloudflare Workers](https://workers.cloudflare.com) function, which will send a `POST` request to GitHub's API and trigger a new deploy:
|
||||
|
||||
```js
|
||||
const headers = {
|
||||
Accept: 'application/vnd.github.everest-preview+json',
|
||||
Authorization: 'Bearer $token',
|
||||
}
|
||||
|
||||
const body = JSON.stringify({ event_type: 'repository_dispatch' })
|
||||
|
||||
const url = `https://api.github.com/repos/$owner/$repo/dispatches`
|
||||
|
||||
const handleRequest = async evt => {
|
||||
await fetch(url, { method: 'POST', headers, body })
|
||||
return new Response('OK')
|
||||
}
|
||||
|
||||
addEventListener('fetch', handleRequest)
|
||||
```
|
||||
|
||||
Note that `$token` in this code sample is a GitHub "Personal Access Token". For information on how to generate this token, see the [GitHub documentation on "repository_dispatch"](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event).
|
||||
For more advanced usage or to programmatically trigger the workflow from scripts, check out [the docs](https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event) for making API calls
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -242,7 +227,7 @@ No problem! Check out the [Quick Start guide](https://developers.cloudflare.com/
|
||||
|
||||
To deploy static sites and frontend applications to Workers, check out the documentation for [Workers Sites](https://developers.cloudflare.com/workers/sites).
|
||||
|
||||
Note that this action makes no assumptions about _how_ your project is built! **If you need to run a pre-publish step, like building your application, you need to specify a build step in your Workflow.** For instance, if I have an NPM command called `build`, my workflow TOML might resemble the following:
|
||||
Note that this action makes no assumptions about _how_ your project is built! **If you need to run a pre-publish step, like building your application, you need to specify a build step in your Workflow.** For instance, if I have an NPM command called `build`, my workflow YAML might resemble the following:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
@@ -254,7 +239,7 @@ jobs:
|
||||
- name: Build site
|
||||
run: 'npm run build'
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
uses: cloudflare/wrangler-action@1.3.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user