Deploy CF API #70
Workflow file for this run
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 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.18.2 | |
- 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 |