Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21f14faa06 | |||
| e5fc9a726a | |||
| 4259a86a6b | |||
| aabd478947 | |||
| 3123fc538b | |||
| 1202bb2fe9 | |||
| e5160f5528 | |||
| 1e37135bae | |||
| 1c9291f9bf | |||
| 8dd9410702 | |||
| 844c30604b |
@@ -0,0 +1,65 @@
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
name: Lint
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Lint shell script
|
||||
uses: azohra/shell-linter@v0.3.0
|
||||
with:
|
||||
path: "entrypoint.sh"
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish app
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish app
|
||||
uses: ./
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
environment: "production"
|
||||
workingDirectory: 'test'
|
||||
publish_legacy_credentials:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish app with legacy credentials
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish app
|
||||
uses: ./
|
||||
with:
|
||||
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
|
||||
email: ${{ secrets.CLOUDFLARE_EMAIL }}
|
||||
environment: "production"
|
||||
workingDirectory: 'test'
|
||||
publish_hardcoded_wrangler_version:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish app with hardcoded Wrangler version
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish app
|
||||
uses: ./
|
||||
with:
|
||||
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
|
||||
email: ${{ secrets.CLOUDFLARE_EMAIL }}
|
||||
environment: "production"
|
||||
wranglerVersion: '1.5.0'
|
||||
workingDirectory: 'test'
|
||||
publish_secrets:
|
||||
runs-on: ubuntu-latest
|
||||
name: Publish app with secrets
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish app
|
||||
uses: ./
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
environment: "production"
|
||||
workingDirectory: "test"
|
||||
secrets: |
|
||||
SECRET1
|
||||
SECRET2
|
||||
env:
|
||||
SECRET1: ${{ secrets.SECRET1 }}
|
||||
SECRET2: ${{ secrets.SECRET2 }}
|
||||
@@ -1,33 +0,0 @@
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Lint shell script
|
||||
uses: azohra/shell-linter@v0.1.0
|
||||
with:
|
||||
path: "entrypoint.sh"
|
||||
- name: Publish app with api token
|
||||
uses: signalnerve/wrangler-action@1.1.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
environment: "production"
|
||||
workingDirectory: 'test'
|
||||
- name: Publish app with legacy credentials
|
||||
uses: signalnerve/wrangler-action@1.1.0
|
||||
with:
|
||||
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
|
||||
email: ${{ secrets.CLOUDFLARE_EMAIL }}
|
||||
environment: "production"
|
||||
workingDirectory: 'test'
|
||||
- name: Publish app with hardcoded Wrangler version
|
||||
uses: signalnerve/wrangler-action@1.1.0
|
||||
with:
|
||||
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
|
||||
email: ${{ secrets.CLOUDFLARE_EMAIL }}
|
||||
environment: "production"
|
||||
wranglerVersion: '1.5.0'
|
||||
workingDirectory: 'test'
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v2
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiKey: ${{ secrets.CF_API_KEY }}
|
||||
email: ${{ secrets.CF_EMAIL }}
|
||||
@@ -57,13 +57,13 @@ jobs:
|
||||
|
||||
## Configuration
|
||||
|
||||
If you're using Wrangler's [environments](https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md) feature, you can customize _where_ the action deploys to by passing an `environment` in the `with` block of your workflow:
|
||||
If you're using Wrangler's [environments](https://developers.cloudflare.com/workers/tooling/wrangler/configuration/environments/) feature, you can customize _where_ the action deploys to by passing an `environment` in the `with` block of your workflow:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.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.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
wranglerVersion: '1.6.0'
|
||||
@@ -87,12 +87,30 @@ Optionally, you can also pass a `workingDirectory` key to the action. This will
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
workingDirectory: 'subfoldername'
|
||||
```
|
||||
|
||||
[Worker secrets](https://developers.cloudflare.com/workers/tooling/wrangler/secrets/) can be optionally passed as a new line deliminated string of names in `secrets`. Each secret name must match an environment variable name specified in the `env` attribute. Creates or replaces the value for the Worker secret using the `wrangler secret put` command.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
workingDirectory: 'subfoldername'
|
||||
secrets: |
|
||||
SECRET1
|
||||
SECRET2
|
||||
env:
|
||||
SECRET1: ${{ secrets.SECRET1 }}
|
||||
SECRET2: ${{ secrets.SECRET2 }}
|
||||
```
|
||||
|
||||
## Use cases
|
||||
|
||||
### Deploying when commits are merged to master
|
||||
@@ -112,7 +130,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -135,7 +153,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish app
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -157,7 +175,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish app
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
@@ -208,7 +226,7 @@ jobs:
|
||||
- name: Build site
|
||||
run: 'npm run build'
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@1.1.0
|
||||
uses: cloudflare/wrangler-action@1.2.0
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
```
|
||||
|
||||
+9
-6
@@ -1,11 +1,11 @@
|
||||
name: 'Deploy to Cloudflare Workers with Wrangler'
|
||||
name: "Deploy to Cloudflare Workers with Wrangler"
|
||||
branding:
|
||||
icon: 'upload-cloud'
|
||||
color: 'orange'
|
||||
description: 'Deploy your Cloudflare Workers applications and sites directly from GitHub, using Wrangler'
|
||||
icon: "upload-cloud"
|
||||
color: "orange"
|
||||
description: "Deploy your Cloudflare Workers applications and sites directly from GitHub, using Wrangler"
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
inputs:
|
||||
apiKey:
|
||||
description: "(Legacy) Your Cloudflare API Key"
|
||||
@@ -19,3 +19,6 @@ inputs:
|
||||
description: "The relative path which Wrangler commands should be run from"
|
||||
wranglerVersion:
|
||||
description: "The version of Wrangler you'd like to use to publish your Workers project"
|
||||
secrets:
|
||||
description: "A new line deliminated string of environment variable names that should be configured as Worker secrets"
|
||||
required: false
|
||||
|
||||
+17
-13
@@ -3,20 +3,8 @@
|
||||
set -e
|
||||
|
||||
export HOME="/github/workspace"
|
||||
export NVM_DIR="/github/workspace/nvm"
|
||||
export WRANGLER_HOME="/github/workspace"
|
||||
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
|
||||
|
||||
# Comments beginning with "shellcheck" use shellcheck, a shell script linter.
|
||||
# The below comments ignore shellcheck linting on the instructions provided
|
||||
# by NVM.
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
# shellcheck source=/dev/null
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
|
||||
mkdir -p "$HOME/.wrangler"
|
||||
chmod -R 770 "$HOME/.wrangler"
|
||||
|
||||
@@ -70,12 +58,28 @@ then
|
||||
cd "$INPUT_WORKINGDIRECTORY"
|
||||
fi
|
||||
|
||||
# If an environment is detected as input
|
||||
secret_not_found() {
|
||||
echo "::error::Specified secret \"$1\" not found in environment variables."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# If an environment is detected as input, for each secret specified get the value of
|
||||
# the matching named environment variable then configure using wrangler secret put.
|
||||
if [ -z "$INPUT_ENVIRONMENT" ]
|
||||
then
|
||||
wrangler publish
|
||||
|
||||
for SECRET in $INPUT_SECRETS; do
|
||||
VALUE=$(printenv "$SECRET") || secret_not_found "$SECRET"
|
||||
echo "$VALUE" | wrangler secret put "$SECRET"
|
||||
done
|
||||
else
|
||||
wrangler publish -e "$INPUT_ENVIRONMENT"
|
||||
|
||||
for SECRET in $INPUT_SECRETS; do
|
||||
VALUE=$(printenv "$SECRET") || secret_not_found "$SECRET"
|
||||
echo "$VALUE" | wrangler secret put "$SECRET" --env "$INPUT_ENVIRONMENT"
|
||||
done
|
||||
fi
|
||||
|
||||
# If a working directory is detected as input, revert to the
|
||||
|
||||
@@ -34,6 +34,14 @@ async function handleEvent(event) {
|
||||
*/
|
||||
// options.mapRequestToAsset = handlePrefix(/^\/docs/)
|
||||
|
||||
// Path to test secrets passed through Wrangler Action. Create SECRET1 and SECRET2 secrets
|
||||
// in the Action repo to something innocuous like "Hello" and "World!".
|
||||
if (url.pathname === "/secret") {
|
||||
let sec1 = (typeof SECRET1 !== 'undefined') ? SECRET1 : ""
|
||||
let sec2 = (typeof SECRET2 !== 'undefined') ? SECRET2 : ""
|
||||
return new Response(`${sec1} ${sec2}`)
|
||||
}
|
||||
|
||||
try {
|
||||
if (DEBUG) {
|
||||
// customize caching
|
||||
|
||||
Reference in New Issue
Block a user