Compare commits

...

11 Commits

Author SHA1 Message Date
Kristian Freeman 21f14faa06 Bump version in README 2020-06-22 10:32:48 -05:00
Kristian Freeman e5fc9a726a Merge pull request #28 from bradyjoslin/master
add secrets publishing
2020-06-22 10:27:18 -05:00
Brady Joslin 4259a86a6b Update deploy.yml 2020-06-22 10:02:00 -05:00
Joslin, Brady W (Brady) aabd478947 update test worker for testing secrets 2020-06-22 09:35:46 -05:00
Joslin, Brady W (Brady) 3123fc538b add secrets publishing 2020-06-15 23:09:55 -05:00
Jason Gill 1202bb2fe9 Remove nvm to speed build time
The Dockerfile already pulls the node:12 image, so there's no need for NVM to be downloaded and installed as well. Removing this speeds up the image build time (making Github Actions go faster)
2020-05-05 13:31:27 -05:00
Kristian Freeman e5160f5528 Merge pull request #14 from cloudflare/kristian/workflow
re-add GitHub Actions workflow
2020-05-05 13:01:29 -05:00
Kristian Freeman 1e37135bae Update workflow and separate into multiple jobs 2020-05-05 12:52:41 -05:00
Kristian Freeman 1c9291f9bf Merge pull request #23 from mscoutermarsh/patch-1
Improvements to the readme
2020-04-06 10:59:14 -05:00
Mike Coutermarsh 8dd9410702 Improvements to the readme
Setting checkout to V2 and fixing the environment link
2020-04-04 20:57:36 -07:00
Kristian Freeman 844c30604b Add workflow 2019-12-13 15:29:17 -06:00
6 changed files with 129 additions and 64 deletions
+65
View File
@@ -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 }}
-33
View File
@@ -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'
+30 -12
View File
@@ -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
View File
@@ -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
View File
@@ -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
+8
View File
@@ -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