Skip to content

fix: hide ended-contest notifications and fix scoreboard chart rendering #54

fix: hide ended-contest notifications and fix scoreboard chart rendering

fix: hide ended-contest notifications and fix scoreboard chart rendering #54

name: Deploy Frontend to Vercel
on:
push:
branches: [ main ]
paths:
- 'frontend/**'
- '.github/workflows/frontend-deploy.yml'
jobs:
deploy:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache-dependency-path: cli/go.sum
- name: Build CLI Binaries
working-directory: cli
run: |
mkdir -p ../frontend/public/bin
API_URL="${{ secrets.PROD_API_URL }}"
# If the secret is just the domain, add /api prefix
if [[ ! $API_URL == */api ]]; then
# But only if it doesn't already have it
API_URL="${API_URL%/}/api"
fi
FRONTEND_URL="https://ctf.rootaccess.live"
LDFLAGS="-s -w -X 'github.com/Uttam-Mahata/RootAccess/cli/internal/config.DefaultBaseURL=$API_URL' -X 'github.com/Uttam-Mahata/RootAccess/cli/internal/config.DefaultFrontendURL=$FRONTEND_URL'"
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o ../frontend/public/bin/rootaccess-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o ../frontend/public/bin/rootaccess-linux-arm64 main.go
GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o ../frontend/public/bin/rootaccess-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o ../frontend/public/bin/rootaccess-darwin-arm64 main.go
GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o ../frontend/public/bin/rootaccess-windows-amd64.exe main.go
- name: Install dependencies
working-directory: frontend
run: npm ci
- name: Inject Environment Variables
working-directory: frontend
run: |
API_URL="${{ secrets.PROD_API_URL }}"
# Use PROD_WS_URL if provided, otherwise derive from API_URL
WS_URL="${{ secrets.PROD_WS_URL }}"
if [ -z "$WS_URL" ]; then
WS_URL=$(echo $API_URL | sed 's/^http/ws/')
fi
SITE_URL="${{ secrets.PROD_SITE_URL }}"
# Replace in both dev and prod environment files
sed -i "s|API_URL_PLACEHOLDER|$API_URL|g" src/environments/environment.ts
sed -i "s|WS_URL_PLACEHOLDER|$WS_URL|g" src/environments/environment.ts
sed -i "s|API_URL_PLACEHOLDER|$API_URL|g" src/environments/environment.prod.ts
sed -i "s|WS_URL_PLACEHOLDER|$WS_URL|g" src/environments/environment.prod.ts
# Override siteUrl if PROD_SITE_URL secret is provided (optional)
if [ -n "$SITE_URL" ]; then
sed -i "s|https://ctf.rootaccess.live|$SITE_URL|g" src/environments/environment.ts
sed -i "s|https://ctf.rootaccess.live|$SITE_URL|g" src/environments/environment.prod.ts
fi
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
working-directory: frontend
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Build for production
working-directory: frontend
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Deploy to Vercel
working-directory: frontend
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}