ci: Add smart deployment pipeline

This commit is contained in:
2026-02-08 18:14:10 +05:30
parent 027f1655b0
commit 30f149fbe3
6 changed files with 7055 additions and 9 deletions

45
.gitea/deploy.yaml Normal file
View File

@@ -0,0 +1,45 @@
name: Smart Deploy
run-name: Deploying ${{ gitea.ref_name }} 🚀
on: [push]
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install Dependencies
run: npm ci
- name: Build Astro Site
run: npm run build
# env:
# PUBLIC_API_URL: ${{ secrets.PUBLIC_API_URL }}
# ---------------------------------------------------------
# CASE 1: PRODUCTION (Main Branch)
# ---------------------------------------------------------
- name: Deploy to Production
if: gitea.ref == 'refs/heads/main'
run: npx netlify-cli deploy --prod --dir=dist --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --message "Prod: ${{ gitea.sha }}"
# ---------------------------------------------------------
# CASE 2: PREVIEW (Any other branch)
# ---------------------------------------------------------
- name: Deploy Preview with Subdomain
if: gitea.ref != 'refs/heads/main'
run: |
# 1. Get the branch name (e.g., 'feature/login')
# 2. Replace slashes with dashes (e.g., 'feature-login') because URLs can't have slashes
ALIAS=$(echo "${{ gitea.ref_name }}" | tr / -)
echo "Deploying to alias: $ALIAS"
# 3. Deploy with the --alias flag
npx netlify-cli deploy --dir=dist --alias "$ALIAS" --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --message "Preview: $ALIAS"