Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add ability to skip publish
  • Loading branch information
Joslin, Brady W (Brady) committed Aug 12, 2020
1 parent 93b9408 commit 176cda2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/deploy.yml
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +85,6 @@ jobs:
preCommands: echo "*** pre command ***"
postCommands: |
echo "*** post commands ***"
wrangler build
echo "******"
env:
SECRET1: ${{ secrets.SECRET1 }}
Expand Down
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -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
28 changes: 16 additions & 12 deletions entrypoint.sh
Expand Up @@ -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
Expand Down

0 comments on commit 176cda2

Please sign in to comment.