Skip to content

Commit e6c3b0f

Browse files
committed
refactor(deploy): streamline deployment workflow and improve script clarity
1 parent 1b260f6 commit e6c3b0f

File tree

1 file changed

+30
-100
lines changed

1 file changed

+30
-100
lines changed

.github/workflows/deploy.yml

Lines changed: 30 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -12,129 +12,59 @@ jobs:
1212
deploy:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: 📥 Checkout code
15+
- name: ⬇️ Checkout current repo
1616
uses: actions/checkout@v4
17+
with:
18+
path: shadcn-studio/template
19+
20+
- name: ⬇️ Checkout automation-scripts repo
21+
uses: actions/checkout@v4
22+
with:
23+
repository: themeselection/automation-scripts
24+
token: ${{ secrets.GH_PAT }}
25+
path: automation-scripts
1726

1827
- name: 📦 Setup pnpm
1928
uses: pnpm/action-setup@v4
2029
with:
2130
version: latest
31+
- name: ⬇️ Install packages in automation-scripts dir
32+
working-directory: automation-scripts/astro
33+
run: pnpm install
2234

23-
- name: 📦 Setup Node.js
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: '22'
27-
cache: 'pnpm'
28-
29-
- name: 📦 Install dependencies
30-
run: pnpm install --frozen-lockfile
35+
- name: 📦 Install template dependencies
36+
working-directory: shadcn-studio/template
37+
run: pnpm install
3138

32-
- name: 🤖 Configure for demo deployment
39+
- name: 🏗️ Build with automation script
40+
working-directory: automation-scripts/astro
3341
run: |
34-
echo "🤖 Configuring site for demo deployment..."
35-
36-
# Set production site URL
37-
SITE_URL="https://shadcn-astro-{your template name}-landing-page.vercel.app/"
38-
echo "🌐 Setting site URL to: $SITE_URL"
39-
40-
# Update astro.config.mjs site URL
41-
sed -i.bak "s|site: 'http://localhost:4321/'|site: '$SITE_URL'|g" astro.config.mjs
42-
43-
# Update all localhost URLs in astro.config.mjs (for sitemap)
44-
sed -i.bak "s|http://localhost:4321/|$SITE_URL|g" astro.config.mjs
45-
46-
# Update SITE_URL in consts.ts
47-
sed -i.bak "s|export const SITE_URL = 'https://shadcnstudio.com/'|export const SITE_URL = '$SITE_URL'|g" src/consts.ts
48-
49-
# Update robots.txt sitemap URL reference if present
50-
sed -i.bak "s|https://yourdomain.com/|$SITE_URL|g" public/robots.txt
51-
52-
# Update consts.ts to set robots to noindex, nofollow (temporary, only in CI)
53-
sed -i.bak "s/index: true/index: false/g" src/consts.ts
54-
sed -i.bak "s/follow: true/follow: false/g" src/consts.ts
55-
56-
# Replace robots.txt with demo version (temporary, only in CI)
57-
cat > public/robots.txt << 'ROBOTS'
58-
# robots.txt for Demo/Staging Environment
59-
# Automatically generated during deployment to prevent indexing
60-
61-
User-agent: *
62-
Disallow: /
63-
64-
# Block all major search engines
65-
User-agent: Googlebot
66-
Disallow: /
67-
68-
User-agent: Bingbot
69-
Disallow: /
70-
71-
User-agent: Slurp
72-
Disallow: /
73-
74-
User-agent: DuckDuckBot
75-
Disallow: /
76-
77-
User-agent: Baiduspider
78-
Disallow: /
79-
80-
User-agent: YandexBot
81-
Disallow: /
82-
ROBOTS
83-
84-
echo "✅ Configuration updated (temporary for this deployment only)"
85-
echo "📄 Verifying configurations:"
86-
echo "Site URL in astro.config.mjs:"
87-
grep "site:" astro.config.mjs || echo "URL applied"
88-
echo "Site URL in consts.ts:"
89-
grep "SITE_URL" src/consts.ts || echo "URL applied"
90-
91-
- name: 🏗️ Build Astro project
92-
run: pnpm run build
93-
94-
- name: 📦 Prepare Vercel prebuilt output
95-
run: |
96-
echo "📦 Creating Vercel Build Output API structure..."
97-
98-
# Create .vercel/output directory structure
99-
mkdir -p .vercel/output/static
100-
101-
# Copy all build files to static directory
102-
cp -r dist/* .vercel/output/static/
103-
104-
# Create config.json for Vercel Build Output API v3
105-
cat > .vercel/output/config.json << 'EOF'
106-
{
107-
"version": 3,
108-
"routes": [
109-
{
110-
"handle": "filesystem"
111-
}
112-
]
113-
}
114-
EOF
42+
echo "🔧 Building Astro template..."
43+
echo "Repository: ${{ github.repository }}"
44+
echo "Branch: ${{ github.ref_name }}"
45+
echo "Environment: ${{ github.ref_name == 'main' && 'Production 🚀' || 'Preview 🧪' }}"
11546
116-
echo "✅ Vercel prebuilt output ready"
117-
echo "📁 Output structure:"
118-
ls -la .vercel/output/
119-
echo "📄 Files in static:"
120-
ls -la .vercel/output/static/ | head -10
47+
pnpm tsx ./src/shadcn-studio/template/generateBuild.ts \
48+
$([[ "${{ github.ref_name }}" == "main" ]] && echo "--prod") \
49+
--vercel-token ${{ secrets.VERCEL_TOKEN }}
12150
12251
- name: 🚀 Deploy to Vercel
52+
working-directory: shadcn-studio/template
12353
run: |
124-
# Install Vercel CLI
54+
# Install Vercel CLI globally
12555
pnpm add -g vercel@latest
12656
12757
# Link to Vercel project
12858
echo "🔗 Linking to Vercel project..."
129-
pnpm exec vercel link --yes --token ${{ secrets.VERCEL_TOKEN }}
59+
vercel link --yes --token ${{ secrets.VERCEL_TOKEN }}
13060
13161
# Deploy based on branch
13262
if [[ "${{ github.ref_name }}" == "main" ]]; then
13363
echo "🚀 Deploying to Production..."
134-
pnpm exec vercel deploy --prod --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
64+
vercel deploy --prod --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
13565
else
13666
echo "🧪 Deploying to Preview (${{ github.ref_name }})..."
137-
pnpm exec vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
67+
vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes
13868
fi
13969
14070
echo "✅ Deployment completed successfully!"

0 commit comments

Comments
 (0)