Compare commits
1 Commits
3d23ceba92
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 94ee3ae83b |
129
.gitea/workflows/main.yml
Normal file
129
.gitea/workflows/main.yml
Normal file
@ -0,0 +1,129 @@
|
||||
name: CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-dev:
|
||||
if: github.ref == 'refs/heads/develop'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmmirror.com"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Type check
|
||||
run: npm run type-check || true
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint || true
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dev-dist
|
||||
path: dist/
|
||||
retention-days: 1
|
||||
|
||||
deploy-dev:
|
||||
if: github.ref == 'refs/heads/develop'
|
||||
needs: build-dev
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dev-dist
|
||||
path: dist/
|
||||
|
||||
- name: Deploy to dev server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEV_SERVER_IP }}
|
||||
username: root
|
||||
password: ${{ secrets.DEV_SSH_PASSWORD }}
|
||||
port: 22
|
||||
source: "dist/*"
|
||||
target: ${{ secrets.DEV_SERVER_PATH }}
|
||||
strip_components: 0
|
||||
overwrite: true
|
||||
command: |
|
||||
mkdir -p ${{ secrets.DEV_SERVER_PATH }}
|
||||
chmod 755 ${{ secrets.DEV_SERVER_PATH }}
|
||||
|
||||
build-prod:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmmirror.com"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Type check
|
||||
run: npm run type-check || true
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint || true
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: prod-dist
|
||||
path: dist/
|
||||
retention-days: 7
|
||||
|
||||
deploy-prod:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
needs: build-prod
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: prod-dist
|
||||
path: dist/
|
||||
|
||||
- name: Deploy to prod server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.PROD_SERVER_IP }}
|
||||
username: root
|
||||
password: ${{ secrets.PROD_SSH_PASSWORD }}
|
||||
port: 22
|
||||
source: "dist/*"
|
||||
target: ${{ secrets.PROD_SERVER_PATH }}
|
||||
strip_components: 0
|
||||
overwrite: true
|
||||
command: |
|
||||
mkdir -p ${{ secrets.PROD_SERVER_PATH }}
|
||||
chmod 755 ${{ secrets.PROD_SERVER_PATH }}
|
||||
Reference in New Issue
Block a user