diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7f4468d..2b5377d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }} diff --git a/README.md b/README.md index 7325925..3d82948 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index dbc4df7..4f038db 100644 --- a/action.yml +++ b/action.yml @@ -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 \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 6ccda21..51d9195 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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