ci: run d1 migrations during cloudflare deploy #5
This file contains hidden or 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 Cloudflare | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: cloudflare-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| ACP_RUNTIME_REPO_URL: https://github.com/saaskit-dev/acp-runtime.git | |
| EXPO_PUBLIC_RELAY_URL: https://free-relay.saaskit.app | |
| EXPO_PUBLIC_WORKBENCH_ORIGIN: https://free.saaskit.app | |
| RELAY_DOMAIN: free-relay.saaskit.app | |
| WORKBENCH_PAGES_PROJECT: free-app | |
| PNPM_VERSION: 10.30.3 | |
| jobs: | |
| verify: | |
| name: Verify | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Free | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Clone pinned acp-runtime | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| ACP_RUNTIME_REF="$(sed -e 's/[[:space:]]*$//' -e '/^$/d' .acp-runtime-ref | head -n 1)" | |
| if [ -z "$ACP_RUNTIME_REF" ]; then | |
| echo "Missing pinned acp-runtime ref in .acp-runtime-ref" >&2 | |
| exit 1 | |
| fi | |
| rm -rf ../acp-runtime | |
| git init ../acp-runtime | |
| git -C ../acp-runtime remote add origin "$ACP_RUNTIME_REPO_URL" | |
| git -C ../acp-runtime fetch --depth 1 origin "$ACP_RUNTIME_REF" | |
| git -C ../acp-runtime checkout --detach FETCH_HEAD | |
| - name: Install pinned acp-runtime dependencies | |
| run: pnpm --dir ../acp-runtime install --frozen-lockfile | |
| - name: Build pinned acp-runtime | |
| run: | | |
| pnpm --dir ../acp-runtime --filter @saaskit-dev/simulator-agent-acp build | |
| pnpm --dir ../acp-runtime run build:lib | |
| - name: Install Free dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Verify Free | |
| run: | | |
| make typecheck | |
| pnpm --dir apps/workbench typecheck | |
| make test | |
| make pack-local | |
| make package-install-check | |
| make source-install-smoke | |
| deploy-relay: | |
| name: Deploy Relay Worker | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| environment: | |
| name: production | |
| url: https://free-relay.saaskit.app | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| steps: | |
| - name: Checkout Free | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Clone pinned acp-runtime | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| ACP_RUNTIME_REF="$(sed -e 's/[[:space:]]*$//' -e '/^$/d' .acp-runtime-ref | head -n 1)" | |
| if [ -z "$ACP_RUNTIME_REF" ]; then | |
| echo "Missing pinned acp-runtime ref in .acp-runtime-ref" >&2 | |
| exit 1 | |
| fi | |
| rm -rf ../acp-runtime | |
| git init ../acp-runtime | |
| git -C ../acp-runtime remote add origin "$ACP_RUNTIME_REPO_URL" | |
| git -C ../acp-runtime fetch --depth 1 origin "$ACP_RUNTIME_REF" | |
| git -C ../acp-runtime checkout --detach FETCH_HEAD | |
| - name: Install pinned acp-runtime dependencies | |
| run: pnpm --dir ../acp-runtime install --frozen-lockfile | |
| - name: Build pinned acp-runtime | |
| run: | | |
| pnpm --dir ../acp-runtime --filter @saaskit-dev/simulator-agent-acp build | |
| pnpm --dir ../acp-runtime run build:lib | |
| - name: Install Free dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Deploy relay | |
| run: make relay-deploy | |
| deploy-workbench: | |
| name: Deploy Workbench Pages | |
| runs-on: ubuntu-latest | |
| needs: deploy-relay | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| environment: | |
| name: production | |
| url: https://free.saaskit.app | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| steps: | |
| - name: Checkout Free | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Clone pinned acp-runtime | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| ACP_RUNTIME_REF="$(sed -e 's/[[:space:]]*$//' -e '/^$/d' .acp-runtime-ref | head -n 1)" | |
| if [ -z "$ACP_RUNTIME_REF" ]; then | |
| echo "Missing pinned acp-runtime ref in .acp-runtime-ref" >&2 | |
| exit 1 | |
| fi | |
| rm -rf ../acp-runtime | |
| git init ../acp-runtime | |
| git -C ../acp-runtime remote add origin "$ACP_RUNTIME_REPO_URL" | |
| git -C ../acp-runtime fetch --depth 1 origin "$ACP_RUNTIME_REF" | |
| git -C ../acp-runtime checkout --detach FETCH_HEAD | |
| - name: Install pinned acp-runtime dependencies | |
| run: pnpm --dir ../acp-runtime install --frozen-lockfile | |
| - name: Build pinned acp-runtime | |
| run: | | |
| pnpm --dir ../acp-runtime --filter @saaskit-dev/simulator-agent-acp build | |
| pnpm --dir ../acp-runtime run build:lib | |
| - name: Install Free dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Deploy Workbench | |
| run: | | |
| pnpm --dir apps/workbench typecheck | |
| make workbench-deploy |