63 lines
1.5 KiB
YAML
63 lines
1.5 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
name: Restore, build and publish
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: Restore
|
|
run: dotnet restore HuntingAppApi.csproj
|
|
|
|
- name: Build
|
|
run: dotnet build HuntingAppApi.csproj --configuration Release --no-restore
|
|
|
|
- name: Publish
|
|
run: dotnet publish HuntingAppApi.csproj --configuration Release --no-build --output ./artifacts/huntapi
|
|
|
|
- name: Upload published API
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: huntapi
|
|
path: ./artifacts/huntapi
|
|
|
|
deploy:
|
|
name: Build and run Docker container
|
|
runs-on: docker
|
|
needs: build
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Write environment file
|
|
run: |
|
|
cat > .env <<'EOF'
|
|
HUNTAPI_HTTP_PORT=${{ secrets.HUNTAPI_HTTP_PORT }}
|
|
HUNTAPI_CONNECTION_STRING=${{ secrets.HUNTAPI_CONNECTION_STRING }}
|
|
HUNTAPI_JWT_SECRET=${{ secrets.HUNTAPI_JWT_SECRET }}
|
|
HUNTAPI_JWT_ISSUER=${{ secrets.HUNTAPI_JWT_ISSUER }}
|
|
HUNTAPI_JWT_AUDIENCE=${{ secrets.HUNTAPI_JWT_AUDIENCE }}
|
|
EOF
|
|
|
|
- name: Deploy
|
|
run: docker compose up -d --build --remove-orphans
|