ci #15
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v3 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| - name: Install Dependencies | |
| run: | | |
| pnpm install | |
| # install yq | |
| VERSION=v4.2.0 | |
| BINARY=yq_linux_amd64 | |
| wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | |
| tar xz && mv ${BINARY} /usr/local/bin/yq | |
| - name: Deploy Production Version | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_DATABASE_ID: ${{ secrets.CLOUDFLARE_DATABASE_ID }} | |
| run: | | |
| # build application | |
| yq -i '.d1_databases[0].database_id = strenv(CLOUDFLARE_DATABASE_ID)' wrangler.toml | |
| yq -i '.vars.MODE = "mixed"' wrangler.toml | |
| yq -i '.vars.PROVIDER_CLOUDFLARE_BUILTIN = false' wrangler.toml | |
| pnpm build:worker | |
| # build website | |
| cd docs | |
| pnpm install | |
| pnpm build | |
| cp -r ./out/ ../dist/home | |
| cd .. | |
| # deploy to cloudflare | |
| pnpm deploy:worker | |
| - name: Deploy Preview Version | |
| run: | | |
| yq -i '.name = "typix-preview"' wrangler.toml | |
| yq -i '.vars.MODE = "client"' wrangler.toml | |
| yq -i '.vars.PROVIDER_CLOUDFLARE_BUILTIN = true' wrangler.toml | |
| pnpm build:worker | |
| pnpm deploy:worker |