71 lines
2.2 KiB
YAML
71 lines
2.2 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
deployment:
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Test
|
|
run: npm run test
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Upload Build Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
deploy-beta:
|
|
needs: build-and-test
|
|
if: (github.event_name == 'push' && github.ref_name == 'beta') || (github.event_name == 'deployment' && github.event.deployment.environment == 'beta')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Build Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Deploy to Beta via FTP
|
|
env:
|
|
FTP_USERNAME: ${{ secrets.BETA_FTP_USERNAME }}
|
|
FTP_PASSWORD: ${{ secrets.BETA_FTP_PASSWORD }}
|
|
FTP_HOST: ${{ secrets.FTP_HOST }}
|
|
run: |
|
|
sudo apt-get update && sudo apt-get install -y lftp
|
|
lftp -d -u "$FTP_USERNAME","$FTP_PASSWORD" -e "set ssl:verify-certificate no; set ftp:ssl-allow yes; set ftp:ssl-force true; set ftp:ssl-protect-data true; set ftp:passive-mode true; mirror -R dist/ ./; quit" $FTP_HOST
|
|
|
|
deploy-prod:
|
|
needs: build-and-test
|
|
if: (github.event_name == 'push' && github.ref_name == 'main') || (github.event_name == 'deployment' && github.event.deployment.environment == 'production')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Build Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Deploy to Production via FTP
|
|
env:
|
|
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
|
|
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
|
|
FTP_HOST: ${{ secrets.FTP_HOST }}
|
|
run: |
|
|
sudo apt-get update && sudo apt-get install -y lftp
|
|
lftp -d -u "$FTP_USERNAME","$FTP_PASSWORD" -e "set ssl:verify-certificate no; set ftp:ssl-allow yes; set ftp:ssl-force true; set ftp:ssl-protect-data true; set ftp:passive-mode true; mirror -R dist/ ./; quit" $FTP_HOST
|