π Deploy - Demos #5
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: 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-ink-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!" |