50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: gitea.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build & push Docker image
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
|
docker login git.${{ secrets.DOMAIN }} \
|
|
-u ${{ secrets.REGISTRY_USER }} --password-stdin
|
|
docker build -t git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/testapp:latest .
|
|
docker push git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/testapp:latest
|
|
|
|
- name: Deploy to VPS
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
script: |
|
|
cd ~/programs/testapp
|
|
docker compose pull
|
|
docker compose up -d --remove-orphans
|