fodler change
This commit is contained in:
45
.gitea/workflows/deploy.yaml
Normal file
45
.gitea/workflows/deploy.yaml
Normal 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"
|
||||
Reference in New Issue
Block a user