Change worker.js script #2 #3
This file contains 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 Worker to Cloudflare | |
on: | |
push: | |
branches: ["master"] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: worker | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Wrangler | |
run: npm install -g wrangler | |
- name: Replace Worker Name in wrangler.toml | |
run: | | |
WORKER_NAME=${{ secrets.CLOUDFLARE_WORKER_NAME }} || "api" | |
sed -i "s/name = \".*\"/name = \"$WORKER_NAME\"/" ../wrangler.toml | |
- name: Replace Port in worker.js | |
run: | | |
PORT=${{ secrets.SERVER_HTTP_PORT }} || "8080" | |
sed -i "s/__SERVER_HTTP_PORT__/$PORT/g" worker.js | |
- name: Publish the Worker | |
run: wrangler deploy --env production | |
env: | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |