fallback #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
upload: | |
runs-on: ubuntu-latest | |
name: Deploy | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Wrangler | |
run: npm install -g [email protected] | |
- name: Check Wrangler Version | |
run: wrangler --version | |
- name: Verify Secrets | |
run: | | |
if [ -z "${{ secrets.CLOUDFLARE_API_TOKEN }}" ]; then | |
echo "Error: CLOUDFLARE_API_TOKEN is not set." | |
exit 1 | |
fi | |
if [ -z "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" ]; then | |
echo "Error: CLOUDFLARE_ACCOUNT_ID is not set." | |
exit 1 | |
fi | |
- name: Upload Worker Version | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
command: versions upload | |
env: | |
DEBUG: wrangler* | |
- name: Handle Missing Worker | |
if: failure() | |
run: | | |
echo "Worker not found or upload failed. Creating and publishing a new Worker." | |
npx wrangler publish |