Merge pull request #8 from timia2109/feature/prod-templates #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Containerize | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-backend: | |
runs-on: ubuntu-22.04 | |
env: | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/[email protected] | |
with: | |
dotnet-version: "8" | |
cache: true | |
cache-dependency-path: DisplayUtil.csproj | |
- name: Restore NuGet dependencies | |
run: dotnet restore --locked-mode | |
- name: Build server | |
run: dotnet publish -c Release --no-restore | |
- name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: backend-artifacts | |
path: bin/Release/net8.0/publish/ | |
build-docker-image: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
needs: | |
- build-backend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/[email protected] | |
with: | |
name: backend-artifacts | |
path: build/ | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Metadata action | |
id: docker_metadata | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} |