name: Deploy Backend on: workflow_dispatch: inputs: environment: description: "Select environment (STAGE or PROD)" required: true default: "STAGE" type: choice options: - STAGE - PROD jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: 18 - name: Install dependencies working-directory: ./server run: npm install - name: Deploy to Cloudflare Workers working-directory: ./server env: CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN_STAGE }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID_STAGE }} CLOUDFLARE_PROJECT_NAME: gigworks-server run: | npm install -g wrangler if [[ "${{ github.event.inputs.environment }}" == "PROD" ]]; then export CLOUDFLARE_API_TOKEN=${{ secrets.CF_API_TOKEN_PROD }} export CLOUDFLARE_ACCOUNT_ID=${{ secrets.CF_ACCOUNT_ID_PROD }} export CLOUDFLARE_PROJECT_NAME=${{ secrets.CF_PROJECT_NAME_PROD }} fi npm run deploy - name: Notify success run: echo "Deployment to ${{ github.event.inputs.environment }} successful!"