Skip to content

Add CI workflow to build and push container images #1

Add CI workflow to build and push container images

Add CI workflow to build and push container images #1

name: Build and push API & Blazor containers
on:
push:
branches:
- develop
permissions:
contents: read
packages: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Publish API container image
run: |
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRegistry=ghcr.io \
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-api \
-p:ContainerImageTag=${{ github.sha }}
- name: Publish Blazor container image
run: |
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRegistry=ghcr.io \
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-blazor \
-p:ContainerImageTag=${{ github.sha }}
- name: Push API image to GHCR
run: |
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }}
- name: Push Blazor image to GHCR
run: |
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }}