Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
3d9372d
activate workflows for dyphira-git org
Cordtus Nov 25, 2025
8bdcc07
add preview deployment workflow for PRs
Cordtus Nov 25, 2025
60a3083
add path filters to preview workflow
Cordtus Nov 25, 2025
6dc0f04
add path filters to build workflow
Cordtus Nov 25, 2025
1d94749
fix block_height property name in API call
Cordtus Nov 25, 2025
bbcef98
add retry logic for transient PostgREST errors
Cordtus Nov 25, 2025
ccee384
fix workflow permissions for PR comments
Cordtus Nov 25, 2025
aed6be8
Merge pull request #2 from dyphira-git/fix/api-retry-transient-errors
Cordtus Nov 25, 2025
7e8d085
fix Select empty value error on governance page
Cordtus Nov 25, 2025
2b57a9a
Merge pull request #3 from dyphira-git/fix/governance-select-empty-value
Cordtus Nov 25, 2025
76ca5cd
add Submit Proposal details to transaction view
Cordtus Nov 25, 2025
54365f3
Merge pull request #4 from dyphira-git/feat/governance-proposal-ui
Cordtus Nov 25, 2025
f360c24
Merge branch 'main' of github.com:Cordtus/yaci-explorer
Cordtus Nov 26, 2025
c299d96
add UI/theme overhaul implementation plan
Cordtus Nov 26, 2025
3f7321c
migrate UI components to Panda CSS and Ark UI
Cordtus Nov 26, 2025
38e1971
migrate routes and components to Panda CSS
Cordtus Nov 26, 2025
3552e22
Fix TypeScript errors and complete Panda CSS migration
Cordtus Nov 26, 2025
94de2f1
Fix API client to match actual PostgREST schema
Cordtus Nov 26, 2025
ed482a7
Add EVM Contracts and Tokens pages
Cordtus Nov 26, 2025
d93e961
Migrate to Bun tooling and fix CSS generation
Cordtus Nov 26, 2025
fb9f056
Fix UI issues: Select dropdown, grid layouts, CSS integration
Cordtus Nov 26, 2025
c6e7ea5
Replace Vite with native Bun bundler
Cordtus Nov 26, 2025
114fabd
WIP: Bun migration and styling updates
Cordtus Nov 26, 2025
a67a910
Add address type detection (EOA vs Contract) for EVM addresses
Cordtus Nov 26, 2025
799c054
Add bech32/hex address conversion and display both formats
Cordtus Nov 26, 2025
d9e2cf0
Adapt address page UX based on entry format (hex vs bech32)
Cordtus Nov 26, 2025
2c72be1
Fix address detection regex and add MsgMultiSend support
Cordtus Nov 26, 2025
89f79a2
Update CI/CD workflows and Dockerfile for Bun
Cordtus Nov 26, 2025
80c1080
Remove prepare script to fix Docker build
Cordtus Nov 26, 2025
217fee7
Add theme toggle, fix tx page styling, redesign EVM view
Cordtus Nov 27, 2025
f368c56
Fix address detail page: query with bech32, fix grid CSS, update stat…
Cordtus Nov 27, 2025
8d9d777
Preview workflow: show commit SHA and timestamp in comment
Cordtus Nov 27, 2025
6b33c32
Fix account type detection on address detail page
Cordtus Nov 27, 2025
396c613
Fix EVM pages, add governance route, add security hardening
Cordtus Nov 27, 2025
99442ed
Remove governance page (not ready yet)
Cordtus Nov 27, 2025
0a7dbe9
Fix white flash on page load (FOUC)
Cordtus Nov 27, 2025
d680c76
Merge pull request #6 from dyphira-git/feat/ui-theme-overhaul
Cordtus Nov 27, 2025
f5ebf54
Fix UI bugs, improve UX, rebrand to Republic Explorer
Cordtus Nov 27, 2025
491bff1
Add proper search input validation with bech32 checksum
Cordtus Nov 27, 2025
9b2dc59
Replace EVM nav icon with Ethereum logo
Cordtus Nov 27, 2025
61057a6
Add custom chain icons for branding
Cordtus Nov 27, 2025
ab315b5
update ignored
Cordtus Nov 27, 2025
1053e26
Add Republic branding and footer
Cordtus Nov 27, 2025
e219d16
Fix preview workflow to use pull_request_target for secrets access
Cordtus Nov 27, 2025
1a3b0ca
Merge pull request #8 from dyphira-git/fix/preview-workflow-secrets
Cordtus Nov 27, 2025
9e0d29a
Merge branch 'main' into fix/ui-improvements-and-rebranding
Cordtus Nov 27, 2025
c115481
Trigger preview deployment
Cordtus Nov 27, 2025
30f4889
Remove .playwright-mcp from repo, add to gitignore
Cordtus Nov 27, 2025
046f35a
Remove redundant build check on PRs (preview deployment covers it)
Cordtus Nov 27, 2025
a9157cc
UI improvements and dark-only theme
Cordtus Nov 27, 2025
dd8c67c
Simplify analytics page and footer cleanup
Cordtus Nov 27, 2025
81e927b
Remove transaction types panel from analytics
Cordtus Nov 27, 2025
0c24504
Fix TX volume chart, improve chart visibility, reduce page sizes
Cordtus Nov 27, 2025
873c9b7
Add workflow_dispatch trigger for preview deployments
Cordtus Nov 27, 2025
e6c1a34
Improve chart visibility, fix workflow duplicate check
Cordtus Nov 27, 2025
a4f33fa
Fix Docker build caching issue
Cordtus Nov 27, 2025
b397e50
Disable Docker cache for preview builds
Cordtus Nov 27, 2025
1e81a7d
Trigger fresh preview build
Cordtus Nov 27, 2025
b5047cc
Merge pull request #9 from dyphira-git/fix/ui-improvements-and-rebran…
Cordtus Nov 27, 2025
673f203
docs: audit and correct documentation against codebase
Cordtus Nov 28, 2025
7667ac6
optimize CI/CD: single build, push to GHCR, deploy from image
Cordtus Dec 2, 2025
a457c61
fix: add aria-hidden to decorative SVG icons
Cordtus Dec 2, 2025
9aed29c
Merge pull request #10 from dyphira-git/optimize-workflows
Cordtus Dec 2, 2025
138efd9
feat: update panda css theme with republic ai colors
Cordtus Dec 3, 2025
a5b9290
feat: update ui components with republic theme
Cordtus Dec 3, 2025
941749d
feat: update layout with republic styling
Cordtus Dec 3, 2025
cb05f71
feat: update route pages with republic theme
Cordtus Dec 3, 2025
169890c
feat: update analytics charts with green color palette
Cordtus Dec 3, 2025
7734a36
feat: remove vite deps, add runtime config.json
Cordtus Dec 3, 2025
82d4083
fix: resolve lint warnings across codebase
Cordtus Dec 3, 2025
edf5b0c
refactor(ui): use semantic tokens in button, card, badge, input
Cordtus Dec 3, 2025
fd8ed2e
refactor(analytics): use token() utility for chart colors
Cordtus Dec 3, 2025
79d86c1
refactor(routes): use semantic tokens for colors
Cordtus Dec 3, 2025
4ac9b7e
chore: update tsconfig for bun bundler
Cordtus Dec 3, 2025
f43a895
chore: remove VITE_ references, update for runtime config
Cordtus Dec 3, 2025
f887221
chore: update panda dev dependency
Cordtus Dec 3, 2025
a1c714d
fix(ci): authenticate fly with ghcr for preview deploys
Cordtus Dec 3, 2025
7c4021a
fix(ci): docker login before fly deploy
Cordtus Dec 3, 2025
b973772
fix(ci): push to fly registry for preview deploys
Cordtus Dec 3, 2025
21be720
refactor(ci): single build, reuse for preview and prod deploys
Cordtus Dec 3, 2025
6de5e28
refactor: streamline CI/CD to build once and reuse
Cordtus Dec 3, 2025
efb2308
Merge pull request #12 from dyphira-git/fix/ci-workflows
Cordtus Dec 3, 2025
1c68511
Merge branch 'main' into feat/republic-theme
Cordtus Dec 3, 2025
783c4b2
fix: explicitly specify app name in preview deploy
Cordtus Dec 3, 2025
4b3fa59
fix: update discord and twitter footer links
Cordtus Dec 3, 2025
47cb754
Merge branch 'main' into feat/republic-theme
Cordtus Dec 3, 2025
61d4126
refactor: streamline PR workflow into single job
Cordtus Dec 5, 2025
c8efb71
Merge pull request #13 from dyphira-git/fix/streamline-pr-workflow
Cordtus Dec 5, 2025
5dd4339
Merge branch 'main' into feat/republic-theme
Cordtus Dec 5, 2025
6a5328c
Merge pull request #11 from dyphira-git/feat/republic-theme
Cordtus Dec 5, 2025
1664276
feat: auto-enable EVM view when URL contains EVM tx hash
Cordtus Dec 5, 2025
da51539
fix: use explicit --app flag in preview deploy
Cordtus Dec 5, 2025
e1c5759
Merge pull request #15 from dyphira-git/fix/preview-deploy-app-name
Cordtus Dec 5, 2025
2bc094d
Merge branch 'main' into feature/evm-hash-url-support
Cordtus Dec 5, 2025
5d22b17
Merge pull request #14 from dyphira-git/feature/evm-hash-url-support
Cordtus Dec 5, 2025
7643191
fix: updated footer links
farhan711 Dec 5, 2025
6937a2c
Merge pull request #16 from dyphira-git/fix/footer-changes
farhan711 Dec 5, 2025
64bd488
feat: add block, timestamp, confirmations to EVM transaction details
Cordtus Dec 5, 2025
95402ef
fix: use wei instead of arai in EVM view for standard terminology
Cordtus Dec 5, 2025
f60db4f
refactor: remove confirmations count (not relevant for CometBFT)
Cordtus Dec 5, 2025
69ddefb
Merge pull request #17 from dyphira-git/feat/evm-details-improvements
Cordtus Dec 5, 2025
5023217
fix: bech32 validation regex min length (38 not 39)
Cordtus Dec 8, 2025
dd1c861
feat: add token balances display on address page
Cordtus Dec 8, 2025
67dfbf0
fix: lowercase tx hash before API query
Cordtus Dec 8, 2025
b101b59
refactor: use middleware chain query endpoint for balances
Cordtus Dec 8, 2025
b2e9596
Merge pull request #18 from dyphira-git/fix/search-and-tx-lookup
Cordtus Dec 8, 2025
bebb272
feat: add custom Panda CSS patterns and icon tokens
Cordtus Dec 8, 2025
dea8557
refactor(addr): use Panda CSS pattern utilities
Cordtus Dec 8, 2025
233f162
refactor(home, metrics): use Panda CSS pattern utilities
Cordtus Dec 8, 2025
5302ca8
fix: add full width to layout containers to fix shrinking issue
Cordtus Dec 8, 2025
2490e53
fix: add full width to remaining layout containers
Cordtus Dec 8, 2025
4d4240d
fix: add full width to remaining page containers
Cordtus Dec 8, 2025
9d1d139
fix: add full width to analytics and EVM page containers
Cordtus Dec 8, 2025
66d92bf
style: increase main content max-width from 6xl to 8xl
Cordtus Dec 9, 2025
b780261
Merge pull request #19 from dyphira-git/refactor/panda-patterns
Cordtus Dec 9, 2025
1effefc
fix: remove chain reset guard feature
Cordtus Jan 23, 2026
b847074
Merge pull request #20 from dyphira-git/fix/remove-reset-guard-dyphira
Cordtus Jan 23, 2026
ea50f1d
feat: add Republic AI testnet chain config and fix favicon
Cordtus Jan 23, 2026
217c52b
feat: visual distinction for SDK framework events and Republic module…
Cordtus Jan 26, 2026
67e5470
feat: add Republic protocol custom module support
Cordtus Jan 26, 2026
b9fc189
fix: update footer to match main site, declutter header nav
Cordtus Jan 26, 2026
7e3fb0d
Merge pull request #22 from dyphira-git/fix/event-type-ux
Cordtus Jan 26, 2026
fc353e8
Merge branch 'main' into feat/republic-custom-modules
Cordtus Jan 26, 2026
ba742ef
Merge pull request #23 from dyphira-git/feat/republic-custom-modules
Cordtus Jan 27, 2026
4abf01a
feat: add validators list and detail pages
Cordtus Jan 27, 2026
e4d976c
Merge pull request #24 from dyphira-git/feat/validators-page
Cordtus Jan 27, 2026
c28fdb0
refactor: remove Network tab, merge IPFS data into Validators
Cordtus Jan 27, 2026
168295b
fix: address linking, EVM field mismatch, stat card padding
Cordtus Jan 27, 2026
fe1a2f9
fix: label wallet tx role as Sender/Related instead of OUT/IN
Cordtus Jan 27, 2026
b672c8f
Merge branch 'main' into feat/validators-page
Cordtus Jan 27, 2026
186ff8a
Merge pull request #25 from dyphira-git/feat/validators-page
Cordtus Jan 27, 2026
f403fb7
fix: format token amounts, warm chain info cache, fix delegator check…
Cordtus Jan 27, 2026
837d90a
Merge branch 'main' into feat/validators-page
Cordtus Jan 27, 2026
99f77ab
fix: normalize commission rates, merge IPFS into validators table
Cordtus Jan 27, 2026
a844ad1
Merge pull request #26 from dyphira-git/feat/validators-page
Cordtus Jan 27, 2026
b4ac24d
fix: remove token amount from voting power column
Cordtus Jan 27, 2026
8e21373
fix: add content-hash cache busting to prevent stale deployments
Cordtus Jan 27, 2026
d45bc34
Merge branch 'main' into feat/validators-page
Cordtus Jan 27, 2026
5908298
Merge pull request #27 from dyphira-git/feat/validators-page
Cordtus Jan 27, 2026
b1ccde5
fix: prefer message-specific events over system events in tx detail
Cordtus Jan 27, 2026
132f4d2
fix: restore favicon link in generated HTML, remove missing logo refe…
Cordtus Jan 28, 2026
ee5931d
Merge branch 'main' into feat/validators-page
Cordtus Jan 28, 2026
b70171e
fix: destroy old preview apps before deploying new one
Cordtus Jan 28, 2026
f01876b
Merge pull request #28 from dyphira-git/feat/validators-page
Cordtus Jan 28, 2026
0a4b3c2
fix: remove Testnet Faucet link from footer
Cordtus Jan 28, 2026
3b15e1b
fix: use query-based chain info for Total Bonded stat
Cordtus Jan 28, 2026
f983c3c
feat: add handlers for 11 missing Cosmos SDK message types
Cordtus Jan 28, 2026
acc2283
Merge pull request #29 from dyphira-git/feat/validators-page
Cordtus Jan 28, 2026
72ba9f6
fix: MsgUnjail validator field name, remove raw fee display
Cordtus Jan 28, 2026
c5ea897
Merge pull request #30 from dyphira-git/feat/validators-page
Cordtus Jan 28, 2026
1532096
feat: add address links and copy feedback across all pages
Cordtus Jan 28, 2026
c1ea927
Merge pull request #31 from dyphira-git/feat/validators-page
Cordtus Jan 28, 2026
c4a94ec
fix: validator detail denom display and empty section handling (#32)
Cordtus Jan 31, 2026
f6e92a6
feat: improve validators page sorting and display (#33)
Cordtus Jan 31, 2026
2e47b29
Feat/validators page (#34)
Cordtus Feb 1, 2026
5e73541
fix: count only COMMIT signatures for active validators (#35)
Cordtus Feb 2, 2026
4835661
Update Discord link in footer component
Cordtus Feb 4, 2026
47b6ec4
feat: add jailing events to validators pages (#37)
Cordtus Feb 4, 2026
97cf3f5
feat: add staking management with wallet connection (#38)
Cordtus Feb 4, 2026
cf9af30
fix: wrap app with AppKitProvider and WalletProvider
Cordtus Feb 4, 2026
14900d6
fix: make wallet providers optional to handle bundler issues
Cordtus Feb 4, 2026
1ca2392
fix: replace AppKit with direct wagmi connection
Cordtus Feb 4, 2026
c7681f3
fix(ui): improve header layout and wallet button styling
Cordtus Feb 4, 2026
448dfcd
fix: replace external Keplr logo with inline SVG
Cordtus Feb 4, 2026
640af65
fix(wallet): use portal to render modal outside header stacking context
Cordtus Feb 4, 2026
207de01
feat(contracts): add detailed contract page with function calls and 4…
Cordtus Feb 4, 2026
e99bcee
fix(wallet): replace wagmi with direct EIP-1193 provider access
Cordtus Feb 4, 2026
14999fa
feat(wallet): add EVM balance fetching via JSON-RPC
Cordtus Feb 4, 2026
93a2c62
fix(keplr): use middleware proxy for Cosmos REST API calls
Cordtus Feb 4, 2026
74ec374
refactor(keplr): use gRPC endpoints for all chain queries
Cordtus Feb 4, 2026
809abaf
feat: redesign analytics page and add validator metrics
Cordtus Feb 5, 2026
9a654f0
feat: enhance wallet dropdown with balance and delegations
Cordtus Feb 5, 2026
6d5b983
fix: resolve lint errors
Cordtus Feb 5, 2026
ada4cf2
feat: enable block results indexing in yaci
Cordtus Feb 5, 2026
ba7062d
feat: add validator signing metrics and wallet balance fallback
Cordtus Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# VCS
.git
.gitignore

# Environment and secrets
.env
.env.*
*.env

# Node/Bun artifacts
node_modules
dist
styled-system
*.log

# Dev tools and cache
.DS_Store
.react-router
.playwright-mcp
test-results
coverage
47 changes: 1 addition & 46 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ POSTGRES_DB=yaci
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

# Derived connection string for reset guard / scripts (leave blank to auto-build)
RESET_GUARD_DB_URI=
# Set to true automatically by scripts/configure-env.sh after prompting once
SKIP_ENV_PROMPTS=false

Expand All @@ -19,7 +17,6 @@ PGRST_DB_SCHEMA=api
POSTGREST_PORT=3000
POSTGREST_URL=http://localhost:3000
POSTGREST_PROXY_URI=http://localhost:3000
VITE_POSTGREST_URL=/api

# -----------------------------------------------------------------------------
# Chain/indexer settings
Expand All @@ -38,57 +35,15 @@ YACI_INSECURE=-k
YACI_METRICS_PORT=2112

# -----------------------------------------------------------------------------
# Frontend defaults (trim or override as needed)
# Frontend defaults (configure via public/config.json instead)
# -----------------------------------------------------------------------------
EXPLORER_PORT=3001
NODE_ENV=production
VITE_CHAIN_REST_ENDPOINT=http://localhost:1317
VITE_QUERY_STALE_MS=10000
VITE_QUERY_GC_MS=300000
VITE_TX_PAGE_SIZE=20
VITE_SEARCH_ADDRESS_LIMIT=20
VITE_SEARCH_AUTO_NAVIGATE_SINGLE=true
VITE_ANALYTICS_VOLUME_HOURS=24
VITE_ANALYTICS_VOLUME_REFRESH_MS=60000
VITE_ANALYTICS_MESSAGE_SAMPLE_LIMIT=10000
VITE_ANALYTICS_MESSAGE_TOPN=10
VITE_ANALYTICS_MESSAGE_REFRESH_MS=60000
VITE_ANALYTICS_BLOCK_INTERVAL_LOOKBACK=100
VITE_ANALYTICS_BLOCK_INTERVAL_REFRESH_MS=30000
VITE_ANALYTICS_BLOCK_INTERVAL_MAX_SECONDS=100
VITE_ANALYTICS_NETWORK_BLOCK_WINDOW=100
VITE_ANALYTICS_NETWORK_TX_WINDOW=1000
VITE_ANALYTICS_NETWORK_MSG_WINDOW=2000
VITE_ANALYTICS_NETWORK_REFRESH_MS=10000
VITE_RESET_NOTICE_ENABLED=true
VITE_RESET_NOTICE_REFETCH_MS=30000
VITE_RESET_NOTICE_HASH_CHECK_HEIGHT=5

# -----------------------------------------------------------------------------
# Chain metadata overrides (optional)
# -----------------------------------------------------------------------------
CHAIN_ID=
CHAIN_NAME=

# -----------------------------------------------------------------------------
# Branding (optional - leave blank to use defaults)
# -----------------------------------------------------------------------------
VITE_APP_NAME=
VITE_APP_NAME_SHORT=
VITE_LOGO_URL=
VITE_FAVICON_URL=
VITE_PRIMARY_COLOR=
VITE_ACCENT_COLOR=
VITE_FOOTER_TEXT=
VITE_LINK_WEBSITE=
VITE_LINK_DOCS=
VITE_LINK_GITHUB=
VITE_LINK_DISCORD=
VITE_LINK_TWITTER=

# -----------------------------------------------------------------------------
# Reset guard (optional)
# -----------------------------------------------------------------------------
ENABLE_CHAIN_RESET_GUARD=false
RESET_GUARD_RPC_ENDPOINT=
RESET_GUARD_AUTO_TRUNCATE=true
59 changes: 40 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
name: build
name: Deploy Production

on:
pull_request:
branches:
- main
push:
branches:
- main
branches: [main]

concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true

env:
FLY_APP: yaci-explorer

jobs:
build:
name: Build
deploy:
name: Deploy to Fly.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
- uses: superfly/flyctl-actions/setup-flyctl@master

- name: Log in to Fly Registry
uses: docker/login-action@v3
with:
node-version: '20'
cache: 'yarn'
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get merge commit SHA
id: sha
run: |
# For PRs merged to main, get the head SHA from the merge commit
MERGE_SHA=$(git log -1 --format=%H)
# Get the PR head SHA (second parent of merge commit)
PR_SHA=$(git log -1 --format=%P | awk '{print $2}')
if [ -n "$PR_SHA" ]; then
echo "sha=$PR_SHA" >> $GITHUB_OUTPUT
else
# Direct push to main - build fresh
echo "sha=" >> $GITHUB_OUTPUT
fi

- name: Type check
run: yarn typecheck
- name: Deploy from existing image
if: steps.sha.outputs.sha != ''
run: flyctl deploy --image registry.fly.io/${{ env.FLY_APP }}:${{ steps.sha.outputs.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: Build
run: yarn build
- name: Build and deploy (direct push)
if: steps.sha.outputs.sha == ''
run: flyctl deploy
env:
VITE_POSTGREST_URL: https://yaci-postgrest.fly.dev
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
24 changes: 0 additions & 24 deletions .github/workflows/deploy.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/preview-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Preview Cleanup

on:
pull_request_target:
types: [closed]

jobs:
cleanup:
runs-on: ubuntu-latest
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
steps:
- uses: superfly/flyctl-actions/setup-flyctl@master

- name: Delete preview app
run: |
PREVIEW_APP="yaci-explorer-pr-${{ github.event.pull_request.number }}"
if flyctl apps list | grep -q "$PREVIEW_APP"; then
echo "Deleting preview app: $PREVIEW_APP"
flyctl apps destroy "$PREVIEW_APP" --yes
else
echo "Preview app $PREVIEW_APP does not exist, skipping"
fi
171 changes: 171 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
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: Destroy old preview apps
run: |
CURRENT_APP="yaci-explorer-pr-${{ github.event.pull_request.number }}"
for app in $(flyctl apps list --json | jq -r '.[].Name' | grep '^yaci-explorer-pr-'); do
if [ "$app" != "$CURRENT_APP" ]; then
echo "Destroying old preview app: $app"
flyctl apps destroy "$app" --yes || true
fi
done
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- 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
});
}
Loading