Initial commit from template
Some checks failed
Cloudflare Worker API Template / Deploy to ${{ github.ref_name }} environment (push) Failing after 15s
Some checks failed
Cloudflare Worker API Template / Deploy to ${{ github.ref_name }} environment (push) Failing after 15s
This commit is contained in:
70
.github/workflows/deploy.yaml
vendored
Normal file
70
.github/workflows/deploy.yaml
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
name: Cloudflare Worker API Template
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev, main, playtest ]
|
||||
pull_request:
|
||||
branches: [ dev, main, playtest ]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:20-bullseye
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
# Extract branch name from ref
|
||||
env:
|
||||
BRANCH_NAME: ${{ github.ref_name }}
|
||||
|
||||
name: Deploy to ${{ github.ref_name }} environment
|
||||
|
||||
steps:
|
||||
- name: Set deployment variables
|
||||
id: vars
|
||||
run: |
|
||||
# Extract environment from branch name
|
||||
BRANCH="$BRANCH_NAME"
|
||||
|
||||
# Set environment name and flags based on branch
|
||||
if [[ "$BRANCH" == "main" ]]; then
|
||||
envname="production"
|
||||
env_flag="--env production"
|
||||
elif [[ "$BRANCH" == "dev" ]]; then
|
||||
envname="development"
|
||||
env_flag="--env development"
|
||||
elif [[ "$BRANCH" == "playtest" ]]; then
|
||||
envname="playtest"
|
||||
env_flag="--env playtest"
|
||||
else
|
||||
# Default to development if branch is unknown
|
||||
envname="playtest"
|
||||
env_flag="--env playtest"
|
||||
fi
|
||||
|
||||
# Write outputs for use in later steps
|
||||
echo "envname=$envname" >> $GITHUB_OUTPUT
|
||||
echo "env_flag=$env_flag" >> $GITHUB_OUTPUT
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Install Wrangler CLI
|
||||
run: npm install -g wrangler
|
||||
|
||||
# Variable setting is already done in the first step
|
||||
|
||||
- name: Deploy to ${{ steps.vars.outputs.envname }} Environment
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||
run: |
|
||||
echo "Deploying to ${{ steps.vars.outputs.envname }} environment"
|
||||
wrangler deploy ${{ steps.vars.outputs.env_flag }}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user