This commit is contained in:
@@ -19,27 +19,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Astro Site
|
- name: Build Astro Site
|
||||||
run: npm run build
|
run: npm run build
|
||||||
# env:
|
|
||||||
# PUBLIC_API_URL: ${{ secrets.PUBLIC_API_URL }}
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# CASE 1: PRODUCTION (Main Branch)
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
- name: Deploy to Production
|
- name: Deploy to Production
|
||||||
if: gitea.ref == 'refs/heads/main'
|
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 }}"
|
run: npx netlify-cli deploy --prod --dir=dist --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --message "Prod ${{ gitea.sha }}"
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
- name: Deploy Preview
|
||||||
# CASE 2: PREVIEW (Any other branch)
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
- name: Deploy Preview with Subdomain
|
|
||||||
if: gitea.ref != 'refs/heads/main'
|
if: gitea.ref != 'refs/heads/main'
|
||||||
run: |
|
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 / -)
|
ALIAS=$(echo "${{ gitea.ref_name }}" | tr / -)
|
||||||
|
npx netlify-cli deploy --dir=dist --alias "$ALIAS" --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --message "Preview $ALIAS"
|
||||||
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