3df52e1265
- Changed registry from Aliyun to git.viaeon.com - Use GITEA_TOKEN secret for authentication - Use GITEA_USERNAME variable for username - Image name: git.viaeon.com/admin/anticaptcha
72 lines
1.7 KiB
YAML
72 lines
1.7 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: ./web
|
|
run: npm install
|
|
|
|
- name: Build frontend
|
|
working-directory: ./web
|
|
run: npm run build
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.viaeon.com
|
|
username: ${{ vars.GITEA_USERNAME }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: git.viaeon.com/admin/anticaptcha
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=sha
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
steps:
|
|
- name: Deploy to server
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USER }}
|
|
password: ${{ secrets.SSH_PASSWORD }}
|
|
script: |
|
|
cd /opt/anticaptcha
|
|
docker-compose pull
|
|
docker-compose up -d
|
|
docker image prune -f |