Skip to content

Build / Publish .NET WebAPI Project #128

Build / Publish .NET WebAPI Project

Build / Publish .NET WebAPI Project #128

Workflow file for this run

name: webapi
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "src/api/**"
- "src/Directory.Packages.props"
pull_request:
branches:
- main
paths:
- "src/api/**"
- "src/Directory.Packages.props"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.100
- name: restore dependencies
run: dotnet restore ./src/api/server/Server.csproj
- name: build
run: dotnet build ./src/api/server/Server.csproj --no-restore
- name: test
run: dotnet test ./src/api/server/Server.csproj --no-build --verbosity normal
publish:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: publish to github container registry
working-directory: ./src/api/server/
run: |
dotnet publish -c Release -p:ContainerRepository=ghcr.io/${{ github.repository_owner}}/webapi -p:RuntimeIdentifier=linux-x64
docker push ghcr.io/${{ github.repository_owner}}/webapi --all-tags