feat: validators page, cache busting, and tx detail fixes #35
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: PR Checks | |
| on: | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: pr-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| pull-requests: write | |
| deployments: write | |
| env: | |
| FLY_APP: yaci-explorer | |
| jobs: | |
| check-and-deploy: | |
| name: preview | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Lint | |
| run: bun run lint | |
| - name: Type check | |
| run: bun run typecheck | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Fly Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.fly.io | |
| username: x | |
| password: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: registry.fly.io/${{ env.FLY_APP }}:${{ github.event.pull_request.head.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Create preview app if needed | |
| run: | | |
| PREVIEW_APP="yaci-explorer-pr-${{ github.event.pull_request.number }}" | |
| if ! flyctl apps list | grep -q "$PREVIEW_APP"; then | |
| flyctl apps create "$PREVIEW_APP" --org personal | |
| fi | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Deploy preview | |
| run: | | |
| PREVIEW_APP="yaci-explorer-pr-${{ github.event.pull_request.number }}" | |
| cat > fly.preview.toml << EOF | |
| app = "$PREVIEW_APP" | |
| primary_region = "sjc" | |
| [http_service] | |
| internal_port = 80 | |
| force_https = true | |
| auto_stop_machines = "stop" | |
| auto_start_machines = true | |
| min_machines_running = 0 | |
| processes = ["app"] | |
| [[vm]] | |
| memory = "256mb" | |
| cpu_kind = "shared" | |
| cpus = 1 | |
| EOF | |
| flyctl deploy --app "$PREVIEW_APP" --config fly.preview.toml --image registry.fly.io/${{ env.FLY_APP }}:${{ github.event.pull_request.head.sha }} --ha=false | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Create deployment status | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = ${{ github.event.pull_request.number }}; | |
| const sha = context.payload.pull_request.head.sha; | |
| const previewUrl = `https://yaci-explorer-pr-${prNumber}.fly.dev`; | |
| const deployment = await github.rest.repos.createDeployment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: sha, | |
| environment: 'preview', | |
| auto_merge: false, | |
| required_contexts: [], | |
| transient_environment: true, | |
| production_environment: false, | |
| }); | |
| await github.rest.repos.createDeploymentStatus({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| deployment_id: deployment.data.id, | |
| state: 'success', | |
| environment_url: previewUrl, | |
| log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
| }); | |
| - name: Comment preview URL | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = ${{ github.event.pull_request.number }}; | |
| const sha = '${{ github.event.pull_request.head.sha }}'.slice(0, 7); | |
| const previewUrl = `https://yaci-explorer-pr-${prNumber}.fly.dev`; | |
| const timestamp = new Date().toISOString().replace('T', ' ').slice(0, 19) + ' UTC'; | |
| const body = `**Preview deployment ready!**\n\n${previewUrl}\n\nLast deployed: \`${sha}\` at ${timestamp}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const botComment = comments.find(c => | |
| c.user.type === 'Bot' && c.body.includes('Preview deployment') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: body | |
| }); | |
| } |