name: Plugins/api-doc deployer on: push: branches: - develop - staging - main paths: - "plugins/libs/plugin-types/index.d.ts" - "plugins/libs/plugin-types/REAME.md" - "plugins/tools/typedoc.css" - "plugins/CHANGELOG.md" - "plugins/wrangle-penpot-plugins-api-doc.toml" workflow_dispatch: inputs: gh_ref: description: 'Name of the branch' type: choice required: true default: 'develop' options: - develop - staging - main permissions: contents: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Extract some useful variables id: vars run: | echo "gh_ref=${{ inputs.gh_ref || github.ref_name }}" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ steps.vars.outputs.gh_ref }} # START: Setup Node and PNPM enabling cache - name: Setup Node.js uses: actions/setup-node@v6 with: node-version-file: .nvmrc - name: Enable PNPM working-directory: ./plugins shell: bash run: | corepack enable; corepack install; - name: Get pnpm store path id: pnpm-store working-directory: ./plugins shell: bash run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - name: Cache pnpm store uses: actions/cache@v4 with: path: ${{ steps.pnpm-store.outputs.STORE_PATH }} key: ${{ runner.os }}-pnpm-${{ hashFiles('plugins/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- # END: Setup Node and PNPM enabling cache - name: Install deps working-directory: ./plugins shell: bash run: | pnpm install --no-frozen-lockfile; pnpm add -D -w wrangler@latest; - name: Build docs working-directory: plugins shell: bash run: pnpm run build:doc - name: Select Worker name run: | REF="${{ steps.vars.outputs.gh_ref }}" case "$REF" in main) echo "WORKER_NAME=penpot-plugins-api-doc-pro" >> $GITHUB_ENV ;; staging) echo "WORKER_NAME=penpot-plugins-api-doc-pre" >> $GITHUB_ENV ;; develop) echo "WORKER_NAME=penpot-plugins-api-doc-hourly" >> $GITHUB_ENV ;; *) echo "Unsupported branch ${REF}" && exit 1 ;; esac - name: Deploy to Cloudflare Workers uses: cloudflare/wrangler-action@v3 with: workingDirectory: plugins apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: deploy --config wrangle-penpot-plugins-api-doc.toml --name ${{ env.WORKER_NAME }}