|
67 | 67 | jq 'del(.d1_databases)' | \ |
68 | 68 | docker run -i ghcr.io/pelletier/go-toml:v2 jsontoml > wrangler.toml |
69 | 69 |
|
70 | | - - name: Extract wrangler.toml [main] |
71 | | - id: wrangler-main |
72 | | - working-directory: ${{ github.event.inputs.directory }} |
73 | | - run: | |
74 | | - wrangler_main=$(docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml | jq -r '.main') |
75 | | - echo "WRANGLER_MAIN=${wrangler_main}" >> "$GITHUB_OUTPUT" |
76 | | -
|
77 | 70 | - name: Check for [build] field in wrangler.toml |
78 | 71 | id: check-custom-build |
79 | 72 | working-directory: ${{ github.event.inputs.directory }} |
|
86 | 79 | with: |
87 | 80 | wranglerVersion: ${{ env.wranglerVersion }} |
88 | 81 | workingDirectory: ${{ github.event.inputs.directory }} |
89 | | - 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 }} |
| 82 | + command: deploy --dry-run ${{ env.OUT_DIR }} --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} |
| 83 | + env: |
| 84 | + OUT_DIR: ${{ steps.check-custom-build.outputs.CUSTOM_BUILD == 'false' && format('--outdir={0}', env.outDir) || '' }} |
| 85 | + |
| 86 | + - name: Determine worker entry script |
| 87 | + id: get-script |
| 88 | + working-directory: ${{ github.event.inputs.directory }} |
| 89 | + run: | |
| 90 | + wrangler_main=$(docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml | jq -r '.main') |
| 91 | + echo "wrangler_main: $wrangler_main" |
| 92 | +
|
| 93 | + if [ "${{ steps.check-custom-build.outputs.CUSTOM_BUILD }}" == "false" ]; then |
| 94 | + trimmed_wrangler_main=$(echo ${wrangler_main} | sed 's|^\./||') |
| 95 | + echo "Custom build is false; looking for the bundled script in ${outDir} containing // ${trimmed_wrangler_main}" |
| 96 | + worker_script=$(grep -rl "// ${trimmed_wrangler_main}" "${{ env.outDir }}" | head -n 1) |
| 97 | + echo "Found worker_script: $worker_script" |
| 98 | + else |
| 99 | + echo "Custom build is true; using the wrangler.toml main entry..." |
| 100 | + worker_script="${wrangler_main}" |
| 101 | + fi |
| 102 | +
|
| 103 | + if [ -z "$worker_script" ]; then |
| 104 | + echo "Error: WORKER_SCRIPT is empty!" |
| 105 | + exit 1 |
| 106 | + fi |
| 107 | +
|
| 108 | + echo "WORKER_SCRIPT=${worker_script}" >> "$GITHUB_OUTPUT" |
90 | 109 |
|
91 | 110 | - name: Deploy Worker |
92 | 111 | uses: cloudflare/wrangler-action@v3 |
|
95 | 114 | accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
96 | 115 | wranglerVersion: ${{ env.wranglerVersion }} |
97 | 116 | workingDirectory: ${{ github.event.inputs.directory }} |
98 | | - 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 }} |
| 117 | + command: deploy --no-bundle --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} ${{ steps.get-script.outputs.WORKER_SCRIPT }} |
0 commit comments