Files
AntiCaptcha/.gitea/workflows/build.yml
T
admin 731e00855b
Build and Deploy / build (push) Failing after 3s
Build and Deploy / deploy (push) Has been skipped
fix: CI/CD build errors
- Simplified go.mod with all dependencies
- Fixed generateRandomSecret function
- Updated Dockerfile to use debian bookworm
- Simplified CI workflow to single job
- Fixed Gitea Actions syntax (github.ref)
2026-07-16 09:23:24 +00:00

77 lines
1.9 KiB
YAML

name: Build and Deploy
on:
push:
branches:
- main
tags:
- 'v*'
env:
REGISTRY: registry.cn-hangzhou.aliyuncs.com
IMAGE_NAME: anticaptcha
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 Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
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