add ability to skip publish

This commit is contained in:
Joslin, Brady W (Brady) 2020-08-11 22:46:42 -05:00
parent 93b9408aec
commit 176cda2c0e
4 changed files with 53 additions and 13 deletions

View file

@ -10,6 +10,28 @@ jobs:
uses: azohra/shell-linter@v0.3.0
with:
path: "entrypoint.sh"
build-only:
runs-on: ubuntu-latest
name: Only build the app
steps:
- uses: actions/checkout@v2
- name: Build app
uses: ./
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "test"
publish: false
secrets: |
SECRET1
SECRET2
preCommands: echo "*** pre commands ***"
postCommands: |
echo "*** post commands ***"
wrangler build
echo "******"
env:
SECRET1: ${{ secrets.SECRET1 }}
SECRET2: ${{ secrets.SECRET2 }}
publish:
runs-on: ubuntu-latest
name: Publish app
@ -63,7 +85,6 @@ jobs:
preCommands: echo "*** pre command ***"
postCommands: |
echo "*** post commands ***"
wrangler build
echo "******"
env:
SECRET1: ${{ secrets.SECRET1 }}

View file

@ -126,6 +126,18 @@ jobs:
echo "******"
```
Set the optional `publish` input to false to skip publishing your Worker project and secrets.
```yaml
jobs:
deploy:
steps:
uses: cloudflare/wrangler-action@1.2.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
publish: false
```
## Use cases
### Deploying when commits are merged to master

View file

@ -28,3 +28,6 @@ inputs:
postCommands:
description: "Commands to execute after publishing the Workers project"
required: false
publish:
description: "Set to false to skip publishing your Worker project and secrets. Defaults to true."
required: false

View file

@ -87,21 +87,25 @@ fi
# 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" ]
# Skip if publish is set to false.
if [ "$INPUT_PUBLISH" != "false" ]
then
wrangler publish
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"
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
for SECRET in $INPUT_SECRETS; do
VALUE=$(printenv "$SECRET") || secret_not_found "$SECRET"
echo "$VALUE" | wrangler secret put "$SECRET" --env "$INPUT_ENVIRONMENT"
done
fi
fi
# If postcommands is detected as input