Skip to content

πŸš€ Deploy - Demos #5

πŸš€ Deploy - Demos

πŸš€ Deploy - Demos #5

Workflow file for this run

name: Deploy - Demos
run-name: ${{ github.ref_name == 'main' && 'πŸš€' || 'πŸ§ͺ' }} Deploy - Demos
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v4
- name: πŸ“¦ Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: πŸ“¦ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
- name: πŸ“¦ Install dependencies
run: pnpm install --frozen-lockfile
- name: πŸ€– Configure for demo deployment
run: |
echo "πŸ€– Configuring site for demo deployment..."
# Set production site URL
SITE_URL="https://shadcn-astro-track-landing-page.vercel.app/"
echo "🌐 Setting site URL to: $SITE_URL"
# Update astro.config.mjs site URL
sed -i.bak "s|site: 'http://localhost:4321/'|site: '$SITE_URL'|g" astro.config.mjs
# Update all localhost URLs in astro.config.mjs (for sitemap)
sed -i.bak "s|http://localhost:4321/|$SITE_URL|g" astro.config.mjs
# Update SITE_URL in consts.ts
sed -i.bak "s|export const SITE_URL = 'https://shadcnstudio.com/'|export const SITE_URL = '$SITE_URL'|g" src/consts.ts
# Update robots.txt sitemap URL reference if present
sed -i.bak "s|https://yourdomain.com/|$SITE_URL|g" public/robots.txt
# Update consts.ts to set robots to noindex, nofollow (temporary, only in CI)
sed -i.bak "s/index: true/index: false/g" src/consts.ts
sed -i.bak "s/follow: true/follow: false/g" src/consts.ts
# Replace robots.txt with demo version (temporary, only in CI)
cat > public/robots.txt << 'ROBOTS'
# robots.txt for Demo/Staging Environment
# Automatically generated during deployment to prevent indexing
User-agent: *
Disallow: /
# Block all major search engines
User-agent: Googlebot
Disallow: /
User-agent: Bingbot
Disallow: /
User-agent: Slurp
Disallow: /
User-agent: DuckDuckBot
Disallow: /
User-agent: Baiduspider
Disallow: /
User-agent: YandexBot
Disallow: /
ROBOTS
echo "βœ… Configuration updated (temporary for this deployment only)"
echo "πŸ“„ Verifying configurations:"
echo "Site URL in astro.config.mjs:"
grep "site:" astro.config.mjs || echo "URL applied"
echo "Site URL in consts.ts:"
grep "SITE_URL" src/consts.ts || echo "URL applied"
- name: πŸ—οΈ Build Astro project
run: pnpm run build
- name: πŸ“¦ Prepare Vercel prebuilt output
run: |
echo "πŸ“¦ Creating Vercel Build Output API structure..."
# Create .vercel/output directory structure
mkdir -p .vercel/output/static
# Copy all build files to static directory
cp -r dist/* .vercel/output/static/
# Create config.json for Vercel Build Output API v3
cat > .vercel/output/config.json << 'EOF'
{
"version": 3,
"routes": [
{
"handle": "filesystem"
}
]
}
EOF
echo "βœ… Vercel prebuilt output ready"
echo "πŸ“ Output structure:"
ls -la .vercel/output/
echo "πŸ“„ Files in static:"
ls -la .vercel/output/static/ | head -10
- name: πŸš€ Deploy to Vercel
run: |
# Install Vercel CLI
pnpm add -g vercel@latest
# Link to Vercel project
echo "πŸ”— Linking to Vercel project..."
pnpm exec vercel link --yes --token ${{ secrets.VERCEL_TOKEN }}
# Deploy based on branch
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "πŸš€ Deploying to Production..."
pnpm exec vercel deploy --prod --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
else
echo "πŸ§ͺ Deploying to Preview (${{ github.ref_name }})..."
pnpm exec vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
fi
echo "βœ… Deployment completed successfully!"