ignore .cluade #22
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 Application | |
| # This workflow handles automated deployment for nn-stack. | |
| # It supports two environments: 'dev' branch to 'dev' stage, and 'main' branch to 'prod' stage. | |
| # | |
| # SETUP INSTRUCTIONS: | |
| # To enable automated deployment, add the following secrets to your GitHub repository: | |
| # (Settings -> Secrets and variables -> Actions -> New repository secret) | |
| # | |
| # 1. CLOUDFLARE_API_TOKEN: | |
| # - You can use `pnpm dlx alchemy util create-cloudflare-token` to generate a token that mirrors your current profile's permissions, or `pnpm dlx alchemy util create-cloudflare-token --god-token` for a token with full access. | |
| # | |
| # 2. ALCHEMY_STATE_TOKEN: | |
| # - How to get: Generate a random string. | |
| # - openssl rand -hex 32 | |
| # | |
| # 3. CLOUDFLARE_EMAIL: | |
| # - Your Cloudflare account login email. | |
| # | |
| # 4. ENV_SERVER_DEV / ENV_SERVER_PROD: | |
| # - How to get: The full content of your apps/server/.env file for each stage. | |
| # | |
| # 5. ENV_WEB_DEV / ENV_WEB_PROD: | |
| # - The full content of your frontend .env file for each stage. | |
| # - Must contain FRONTEND=web or FRONTEND=tanstack to select which frontend to deploy. | |
| # - Upload from apps/web/.env for Next.js, or apps/tanstack/.env for TanStack Start. | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| concurrency: | |
| group: deploy-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Inject Environment Files (Dev) | |
| if: github.ref == 'refs/heads/dev' | |
| run: | | |
| echo "${{ secrets.ENV_SERVER_DEV }}" > apps/server/.env | |
| FRONTEND=$(echo "${{ secrets.ENV_WEB_DEV }}" | grep -m1 '^FRONTEND=' | cut -d'=' -f2 | tr -d '[:space:]') | |
| FRONTEND=${FRONTEND:-web} | |
| echo "FRONTEND=$FRONTEND" >> $GITHUB_ENV | |
| echo "${{ secrets.ENV_WEB_DEV }}" > apps/$FRONTEND/.env | |
| - name: Inject Environment Files (Prod) | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| echo "${{ secrets.ENV_SERVER_PROD }}" > apps/server/.env | |
| FRONTEND=$(echo "${{ secrets.ENV_WEB_PROD }}" | grep -m1 '^FRONTEND=' | cut -d'=' -f2 | tr -d '[:space:]') | |
| FRONTEND=${FRONTEND:-web} | |
| echo "FRONTEND=$FRONTEND" >> $GITHUB_ENV | |
| echo "${{ secrets.ENV_WEB_PROD }}" > apps/$FRONTEND/.env | |
| - name: Deploy to Dev | |
| if: github.ref == 'refs/heads/dev' | |
| run: | | |
| pnpm --filter server deploy:dev | |
| pnpm --filter $FRONTEND deploy:dev | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }} | |
| ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }} | |
| - name: Deploy to Prod | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| pnpm --filter server deploy:prod | |
| pnpm --filter $FRONTEND deploy:prod | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }} | |
| ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }} |