Skip to content

Commit 0231784

Browse files
committed
Add CI workflow to build and push container images
Introduced a GitHub Actions workflow to automate building and pushing container images for the API and Blazor projects. The workflow triggers on `push` events to the `develop` branch and includes the following: - Configured permissions for `contents: read` and `packages: write`. - Added a `build-and-push` job running on `ubuntu-latest`. - Steps include: - Checkout repository code using `actions/checkout@v4`. - Setup .NET SDK version `10.0.x` using `actions/setup-dotnet@v4`. - Log in to GitHub Container Registry (GHCR) using `GITHUB_TOKEN`. - Build and publish container images for API and Blazor projects. - Push the container images to GHCR. This workflow ensures the latest container images are built and stored in the registry for the `develop` branch.
1 parent 5707e32 commit 0231784

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and push API & Blazor containers
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET SDK
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: '10.0.x'
24+
25+
- name: Log in to GitHub Container Registry
26+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
27+
28+
- name: Publish API container image
29+
run: |
30+
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
31+
-c Release -r linux-x64 \
32+
-p:PublishProfile=DefaultContainer \
33+
-p:ContainerRegistry=ghcr.io \
34+
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-api \
35+
-p:ContainerImageTag=${{ github.sha }}
36+
37+
- name: Publish Blazor container image
38+
run: |
39+
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
40+
-c Release -r linux-x64 \
41+
-p:PublishProfile=DefaultContainer \
42+
-p:ContainerRegistry=ghcr.io \
43+
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-blazor \
44+
-p:ContainerImageTag=${{ github.sha }}
45+
46+
- name: Push API image to GHCR
47+
run: |
48+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }}
49+
50+
- name: Push Blazor image to GHCR
51+
run: |
52+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }}
53+

0 commit comments

Comments
 (0)