Cleaner github actions organization #16
Workflow file for this run
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: Preview Deploy | |
| # Requires repository secrets: | |
| # - CLOUDFLARE_ACCOUNT_ID: Cloudflare account ID for the worker. | |
| # - CLOUDFLARE_API_TOKEN: Token with Workers Scripts Edit permissions. | |
| # | |
| # Requires preview environment variables: | |
| # - OAUTH_GITHUB_CLIENT_ID: GitHub OAuth app client ID | |
| # | |
| # Requires preview environment secrets: | |
| # - BETTER_AUTH_SECRET: Better Auth secret key | |
| # - OAUTH_GITHUB_CLIENT_SECRET: GitHub OAuth app client secret | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| upload-preview: | |
| name: Upload Worker Preview | |
| runs-on: ubuntu-latest | |
| environment: preview | |
| env: | |
| PR_ALIAS: pr-${{ github.event.number }} | |
| WORKER_NAME: startkit-preview | |
| WORKER_SUBDOMAIN: blendist | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install dependencies | |
| uses: ./.github/actions/setup | |
| - name: Run code quality checks | |
| run: bun run check | |
| - name: Build project | |
| run: bun run build | |
| env: | |
| CLOUDFLARE_ENV: preview | |
| - name: Run database migrations | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: d1 migrations apply DB --remote | |
| packageManager: bun | |
| - name: Upload preview Worker | |
| id: wrangler | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: versions upload --preview-alias ${{ env.PR_ALIAS }} | |
| packageManager: bun | |
| # secrets: | | |
| # BETTER_AUTH_SECRET | |
| # OAUTH_GITHUB_CLIENT_SECRET | |
| vars: | | |
| BETTER_AUTH_URL=${{ format('https://{0}-{1}.{2}.workers.dev', env.PR_ALIAS, env.WORKER_NAME, env.WORKER_SUBDOMAIN) }} | |
| OAUTH_GITHUB_CLIENT_ID=${{ vars.OAUTH_GITHUB_CLIENT_ID }} | |
| env: | |
| CLOUDFLARE_ENV: preview | |
| WRANGLER_CONFIG: ./dist/server/wrangler.json | |
| BETTER_AUTH_SECRET: ${{ secrets.BETTER_AUTH_SECRET }} | |
| OAUTH_GITHUB_CLIENT_SECRET: ${{ secrets.OAUTH_GITHUB_CLIENT_SECRET }} | |
| - name: Find existing comment | |
| uses: peter-evans/find-comment@v3 | |
| id: find-comment | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.number }} | |
| comment-author: "github-actions[bot]" | |
| body-includes: "<!-- startkit-preview -->" | |
| - name: Comment preview link | |
| if: success() | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| body: | | |
| <!-- startkit-preview --> | |
| **StartKit Preview** 🚀 | |
| - PR: `${{ env.PR_ALIAS }}` | |
| - Deployment URL: ${{ steps.wrangler.outputs.deployment-url }} | |
| - PR Preview URL: ${{ format('[https://{0}-{1}.{2}.workers.dev](https://{0}-{1}.{2}.workers.dev)', env.PR_ALIAS, env.WORKER_NAME, env.WORKER_SUBDOMAIN) }} | |
| _Latest preview deployed to the preview environment. Note: All PRs share the same preview worker._ | |
| edit-mode: replace |