feat: полный CI/CD — build на 107, deploy на 111
- build job (ubuntu-latest/107): docker build + push в Gitea Registry - deploy job (lxc-111): docker pull + docker run с network=host - Данные сохраняются в /opt/vpn-proxy/data volume - Ansible плейбук больше не нужен для деплоя Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Deploy Sing-proxy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
DEPLOY_PATH: /opt/vpn-proxy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -31,3 +34,37 @@ jobs:
|
|||||||
|
|
||||||
docker push "${IMAGE}:latest"
|
docker push "${IMAGE}:latest"
|
||||||
echo "Pushed: ${IMAGE}:latest"
|
echo "Pushed: ${IMAGE}:latest"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: lxc-111
|
||||||
|
steps:
|
||||||
|
- name: Deploy to LXC 111
|
||||||
|
run: |
|
||||||
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||||
|
IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}/sing-proxy"
|
||||||
|
|
||||||
|
echo "Logging into registry..."
|
||||||
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY_HOST" -u "${{ gitea.actor }}" --password-stdin
|
||||||
|
|
||||||
|
echo "Pulling latest image..."
|
||||||
|
docker pull "${IMAGE}:latest"
|
||||||
|
|
||||||
|
echo "Stopping old container..."
|
||||||
|
docker stop sing-proxy 2>/dev/null || true
|
||||||
|
docker rm sing-proxy 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "Starting new container..."
|
||||||
|
docker run -d \
|
||||||
|
--name sing-proxy \
|
||||||
|
--network host \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-e PORT=3456 \
|
||||||
|
-e PROXY_PORT=8080 \
|
||||||
|
-v ${{ env.DEPLOY_PATH }}/data:/app/data \
|
||||||
|
--memory=256m \
|
||||||
|
"${IMAGE}:latest"
|
||||||
|
|
||||||
|
echo "Deployment complete!"
|
||||||
|
sleep 3
|
||||||
|
docker ps | grep sing-proxy
|
||||||
|
|||||||
Reference in New Issue
Block a user