Skip to content

Commit

Permalink
create sample specifically for multi-arch-manifest flows
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Feb 14, 2024
1 parent 097c389 commit fcbabfb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/multi-arch-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: multi-arch image sample

on:
push:
workflow_dispatch:

env:
GITHUB_USERNAME: baronfel
APP_NAME: multi-arch-sample

jobs:
create-multiarch-image:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get the code
uses: actions/checkout@v2
- name: build the x64 image
id: build-x64
working-directory: src/multi-arch-sample
run: |
dotnet publish -t:PublishContainer --arch x64 -p ContainerImageLabel=latest-x64 -p ContainerRepository=ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}
echo "generated_container_name=ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}:latest-x64" >> $GITHUB_OUTPUT
- name: build the arm64 image
id: build-arm64
run: |
dotnet publish -t:PublishContainer --arch arm64 -p ContainerImageLabel=latest-arm64 -p ContainerRepository=ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}
echo "generated_container_name=ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}:latest-arm64" >> $GITHUB_OUTPUT
- name: create the multi-image manifest
run: |
docker manifest create ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}:latest \
${{ steps.build-x64.outputs.generated_container_name }} \
${{ steps.build-arm64.outputs.generated_container_name }} \
docker manifest push ghcr.io/${{github.repository_owner}}/${{env.APP_NAME}}:latest
1 change: 1 addition & 0 deletions src/multi-arch-sample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Console.WriteLine($"Hello, World from {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} on {System.Runtime.InteropServices.RuntimeInformation.OSDescription} with {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture} chips!");
12 changes: 12 additions & 0 deletions src/multi-arch-sample/multi-arch-sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>multi_arch_sample</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
</PropertyGroup>

</Project>

0 comments on commit fcbabfb

Please sign in to comment.