53 lines
1.8 KiB
YAML
53 lines
1.8 KiB
YAML
name: ci-cd-nas
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
# Runs in a normal container on the runner — only needs the .NET SDK.
|
|
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
|
|
|
|
# Runs on the NAS runner (label `nas`) which has the host Docker socket mounted
|
|
# and /volume1/docker/rolac bind-mounted at the same path. Builds, pushes to the
|
|
# local Gitea registry, then (re)starts the stack.
|
|
deploy:
|
|
needs: test
|
|
runs-on: nas
|
|
env:
|
|
REGISTRY: git.golife.love/chrischen
|
|
DEPLOY_DIR: /volume1/docker/rolac
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Registry login
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.golife.love -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
|
|
- name: Build images
|
|
run: |
|
|
docker build -t "$REGISTRY/rolac-api:latest" -t "$REGISTRY/rolac-api:${{ github.sha }}" ./API
|
|
docker build -t "$REGISTRY/rolac-app:latest" -t "$REGISTRY/rolac-app:${{ github.sha }}" ./APP
|
|
|
|
- name: Push images
|
|
run: |
|
|
docker push --all-tags "$REGISTRY/rolac-api"
|
|
docker push --all-tags "$REGISTRY/rolac-app"
|
|
|
|
- name: Sync compose + nginx to deploy dir
|
|
run: |
|
|
mkdir -p "$DEPLOY_DIR/nginx/conf.d" "$DEPLOY_DIR/data/api-storage"
|
|
cp deploy/nas/docker-compose.yml "$DEPLOY_DIR/docker-compose.yml"
|
|
cp deploy/nas/nginx/conf.d/rolac.conf "$DEPLOY_DIR/nginx/conf.d/rolac.conf"
|
|
|
|
- name: Deploy
|
|
run: |
|
|
cd "$DEPLOY_DIR"
|
|
docker compose up -d
|
|
sleep 5
|
|
curl -fsS http://localhost:8080/api/health
|