Skip to content

Deploy CF API

Deploy CF API #38

Workflow file for this run

name: Deploy CF API
on:
workflow_dispatch:
inputs:
api:
description: 'API'
required: true
type: choice
options:
- routing
- farms
environment:
description: 'Choose an environment to deploy to: <dev|production>'
required: true
type: choice
default: 'dev'
options:
- dev
- production
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
env:
HAVE_CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN != '' }}
IS_DEV: ${{ github.event.inputs.environment == 'dev' }}
name: Publish API
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
cache: 'pnpm'
node-version: 18
- name: Install dependencies
run: pnpm i --ignore-scripts
- name: Build package
run: pnpm build:packages
- name: Publish
uses: cloudflare/[email protected]
if: ${{ (env.HAVE_CLOUDFLARE_TOKEN == 'true') && (env.IS_DEV == 'false') }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: 'apis/${{ github.event.inputs.api }}'
command: publish --env ${{ github.event.inputs.environment }}
- name: Publish dev
uses: cloudflare/[email protected]
if: ${{ (env.HAVE_CLOUDFLARE_TOKEN == 'true') && (env.IS_DEV == 'true') }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
workingDirectory: 'apis/${{ github.event.inputs.api }}'
command: publish