55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: ci-cd
|
|
on:
|
|
push:
|
|
branches: [azure-deploy]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-dotnet@v4
|
|
with: { dotnet-version: '8.0.x' }
|
|
- run: dotnet test API/ROLAC.API.Tests/ROLAC.API.Tests.csproj -c Release
|
|
|
|
build-push:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: git.golife.love
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./API
|
|
push: true
|
|
tags: |
|
|
git.golife.love/chrischen/rolac-api:latest
|
|
git.golife.love/chrischen/rolac-api:${{ github.sha }}
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./APP
|
|
push: true
|
|
tags: |
|
|
git.golife.love/chrischen/rolac-app:latest
|
|
git.golife.love/chrischen/rolac-app:${{ github.sha }}
|
|
|
|
deploy:
|
|
needs: build-push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.VM_HOST }}
|
|
username: ${{ secrets.VM_USER }}
|
|
key: ${{ secrets.VM_SSH_KEY }}
|
|
script: |
|
|
cd /opt/rolac/deploy
|
|
export TAG=${{ github.sha }}
|
|
docker compose pull
|
|
docker compose up -d
|
|
curl -fsS https://manage.rolac.org/api/health
|