Skip to content

Commit

Permalink
fix(ci): deploy correct bundled script file
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonianb committed Aug 21, 2024
1 parent c3f7b77 commit b326c55
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/deploy-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ jobs:
jq 'del(.d1_databases)' | \
docker run -i ghcr.io/pelletier/go-toml:v2 jsontoml > wrangler.toml
- name: Extract wrangler.toml [main]
id: wrangler-main
working-directory: ${{ github.event.inputs.directory }}
run: |
wrangler_main=$(docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml | jq -r '.main')
echo "WRANGLER_MAIN=${wrangler_main}" >> "$GITHUB_OUTPUT"
- name: Check for [build] field in wrangler.toml
id: check-custom-build
working-directory: ${{ github.event.inputs.directory }}
Expand All @@ -86,7 +79,23 @@ jobs:
with:
wranglerVersion: ${{ env.wranglerVersion }}
workingDirectory: ${{ github.event.inputs.directory }}
command: deploy --dry-run ${{ steps.check-custom-build.outputs.CUSTOM_BUILD == 'false' && format('--outdir={0}', env.outDir) || '' }} --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }}
command: deploy --dry-run ${{ env.OUT_DIR }} --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }}
env:
OUT_DIR: ${{ steps.check-custom-build.outputs.CUSTOM_BUILD == 'false' && format('--outdir={0}', env.outDir) || '' }}

- name: Determine worker entry script
id: get-script
working-directory: ${{ github.event.inputs.directory }}
run: |
wrangler_main=$(docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml | jq -r '.main')
if [ "${{ steps.check-custom-build.outputs.CUSTOM_BUILD }}" == "false" ]; then
worker_script=$(grep -rl "// ${wrangler_main}" ${env.outDir} | head -n 1)
else
worker_script="${wrangler_main}"
fi
echo "WORKER_SCRIPT=${worker_script}" >> "$GITHUB_OUTPUT"
- name: Deploy Worker
uses: cloudflare/wrangler-action@v3
Expand All @@ -95,4 +104,4 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: ${{ env.wranglerVersion }}
workingDirectory: ${{ github.event.inputs.directory }}
command: deploy --no-bundle --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} ${{ steps.check-custom-build.outputs.CUSTOM_BUILD == 'false' && format('{0}/', env.outDir) || '' }}${{ steps.wrangler-main.outputs.WRANGLER_MAIN }}
command: deploy --no-bundle --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} ${{ steps.get-script.outputs.WORKER_SCRIPT }}

0 comments on commit b326c55

Please sign in to comment.