CI/CD пайплайн
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
name: Test & Deploy to Snapdeploy
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-test-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# ---------- Сборка основного образа ----------
|
||||
- name: Build eventhub image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
load: true
|
||||
tags: eventhub:latest
|
||||
|
||||
# ---------- Сборка тестового образа поверх eventhub ----------
|
||||
- name: Build API test image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: docker/ApiTests.Dockerfile
|
||||
load: true
|
||||
tags: eventhub-api-tests:latest
|
||||
|
||||
# ---------- Запуск тестов ----------
|
||||
- name: Run API tests
|
||||
run: |
|
||||
docker run --rm eventhub-api-tests:latest
|
||||
|
||||
# ---------- Пуш основного образа в Registry (опционально) ----------
|
||||
- name: Push eventhub image to Gitea Registry
|
||||
if: success()
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: git.sabilin.com/eventhub/eventhub:test
|
||||
|
||||
# ---------- Деплой на Snapdeploy ----------
|
||||
- name: Deploy to Snapdeploy
|
||||
if: success()
|
||||
run: |
|
||||
# TODO: замените на реальный вызов API Snapdeploy
|
||||
echo "Deploying to Snapdeploy test environment..."
|
||||
# curl -X POST https://api.snapdeploy.dev/deploy \
|
||||
# -H "Authorization: Bearer ${{ secrets.SNAPDEPLOY_TOKEN }}" \
|
||||
# ...
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Deploy to Stage
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
deploy-stage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: git.sabilin.com
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push eventhub
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: git.sabilin.com/eventhub/eventhub:stage
|
||||
|
||||
- name: Build and push bot-emulator
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./docker/bot-emulator-users
|
||||
push: true
|
||||
tags: git.sabilin.com/eventhub/bot-emulator-users:stage
|
||||
|
||||
- name: Deploy to stage server
|
||||
uses: appleboy/ssh-action@v0.1.5
|
||||
with:
|
||||
host: ${{ secrets.STAGE_SSH_HOST }}
|
||||
username: ${{ secrets.STAGE_SSH_USER }}
|
||||
key: ${{ secrets.STAGE_SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
cd /opt/eventhub-stage
|
||||
docker pull git.sabilin.com/eventhub/eventhub:stage
|
||||
docker pull git.sabilin.com/eventhub/bot-emulator-users:stage
|
||||
docker stack deploy -c docker-compose.stage.yml eventhub-stage --with-registry-auth
|
||||
Reference in New Issue
Block a user