ci: Add smart deployment pipeline
This commit is contained in:
45
.gitea/deploy.yaml
Normal file
45
.gitea/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"
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,3 +22,6 @@ pnpm-debug.log*
|
|||||||
|
|
||||||
# jetbrains setting folder
|
# jetbrains setting folder
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# Local Netlify folder
|
||||||
|
.netlify
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import netlify from '@astrojs/netlify';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({});
|
export default defineConfig({
|
||||||
|
vite: {
|
||||||
|
plugins: [tailwindcss()]
|
||||||
|
},
|
||||||
|
|
||||||
|
adapter: netlify()
|
||||||
|
});
|
||||||
6997
package-lock.json
generated
6997
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,9 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "^5.17.1"
|
"@astrojs/netlify": "^6.6.4",
|
||||||
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
|
"astro": "^5.17.1",
|
||||||
|
"tailwindcss": "^4.1.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/styles/global.css
Normal file
1
src/styles/global.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
Reference in New Issue
Block a user