Cleaner github actions organization #4
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 }} | |
| 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: 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 | |
| env: | |
| CLOUDFLARE_ENV: preview | |
| BETTER_AUTH_URL: https://startkit-${{ env.PR_ALIAS }}.blendist.workers.dev | |
| OAUTH_GITHUB_CLIENT_ID: ${{ vars.OAUTH_GITHUB_CLIENT_ID }} | |
| 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** 🚀 | |
| - Alias: `${{ env.PR_ALIAS }}` | |
| - Preview: ${{ steps.wrangler.outputs.deployment-url && format('[Open preview]({0})', steps.wrangler.outputs.deployment-url) || 'Check Wrangler logs for URL' }} | |
| _Re-run the workflow to refresh the preview._ | |
| edit-mode: replace |