feat: auto-enable EVM view when URL contains EVM tx hash #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
| # Disabled - requires FLY_API_TOKEN secret to be configured | |
| # To re-enable: remove 'if: false' from the preview job | |
| name: Preview Deployment | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number to deploy' | |
| required: true | |
| concurrency: | |
| group: preview-${{ github.event.pull_request.number || github.event.inputs.pr_number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| PREVIEW_APP: yaci-explorer-pr-${{ github.event.pull_request.number || github.event.inputs.pr_number }} | |
| jobs: | |
| preview: | |
| if: false # Disabled until FLY_API_TOKEN is configured | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Create or update preview app | |
| run: | | |
| if ! flyctl apps list | grep -q "$PREVIEW_APP"; then | |
| echo "Creating preview app: $PREVIEW_APP" | |
| flyctl apps create "$PREVIEW_APP" --org personal | |
| fi | |
| cat > fly.preview.toml << EOF | |
| app = "$PREVIEW_APP" | |
| primary_region = "sjc" | |
| [build] | |
| [build.args] | |
| VITE_POSTGREST_URL = "https://yaci-explorer-apis.fly.dev" | |
| VITE_CHAIN_REST_ENDPOINT = "https://api.republicai.io" | |
| [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 --config fly.preview.toml --remote-only --no-cache | |
| - name: Post preview URL | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const previewUrl = `https://${process.env.PREVIEW_APP}.fly.dev`; | |
| const sha = context.payload.pull_request.head.sha.slice(0, 7); | |
| 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: context.issue.number, | |
| }); | |
| 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: context.issue.number, | |
| body: body | |
| }); | |
| } |