Merge pull request #13 from PenguLoader/dev #43
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
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| deployments: write | |
| environment: | |
| name: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }} | |
| url: ${{ github.ref == 'refs/heads/main' && 'https://pengu.lol' || 'https://pengu.dev' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Resolve Pages project | |
| env: | |
| PROJECT: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
| run: | | |
| if [[ -z "$PROJECT" ]]; then | |
| echo "::error::CLOUDFLARE_PROJECT_NAME secret is not set." | |
| exit 1 | |
| fi | |
| echo "CF_PAGES_PROJECT=$PROJECT" >> $GITHUB_ENV | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: pnpm | |
| - name: Build project | |
| run: | | |
| pnpm install | |
| pnpm build | |
| # Single Pages project, two domains routed by branch: | |
| # main -> production deployment -> pengu.lol | |
| # dev -> dev.<project>.pages.dev alias -> pengu.dev | |
| # --branch is what picks between them, so it must always be passed. | |
| # pengu.dev reaches the dev build via a proxied CNAME retargeted at the | |
| # branch alias -- see docs/guide or the Cloudflare dashboard DNS tab. | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: >- | |
| pages deploy .vitepress/dist | |
| --project-name=${{ env.CF_PAGES_PROJECT }} | |
| --branch=${{ github.ref_name }} |