Last active
April 2, 2026 20:16
-
-
Save meziantou/e3fa090f06cdfa53409a2487b5b33365 to your computer and use it in GitHub Desktop.
sample
This file contains hidden or 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
| jobs: | |
| publish_docker_linux: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: linux | |
| arch: x64 | |
| - os: linux | |
| arch: arm64 | |
| env: | |
| ContainerImageTagSuffix: ${{ matrix.os }}-${{ matrix.arch }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v5 | |
| - name: run tests | |
| run: dotnet test | |
| - uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.arch }} | |
| path: '**/TestResults/**/*' | |
| - run: docker run --privileged --rm tonistiigi/binfmt --install all | |
| - name: Log in to Docker | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.ContainerRegistry }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: run local docker registry | |
| run: docker run -d -p 5000:5000 --name registry registry:latest | |
| - name: Build base image | |
| working-directory: Test.BaseImage | |
| run: | | |
| $platform = "${{ matrix.os }}/${{ matrix.arch }}".replace('x64', 'amd64') | |
| docker build --tag localhost:5000/test-base:latest-${{env.ContainerImageTagSuffix}} --platform $platform --file Dockerfile . | |
| - name: push base image | |
| working-directory: test.BaseImage | |
| run: docker push localhost:5000/test-base:latest-${{env.ContainerImageTagSuffix}} | |
| - name: Create image | |
| run: dotnet publish test.csproj --os ${{matrix.os}} --arch ${{matrix.arch}} --configuration Release /t:PublishContainer | |
| publish_multiarch: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: [publish_docker_linux] | |
| steps: | |
| - name: Log in to Docker | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - run: | | |
| $image = "${{env.ContainerRegistry}}/${{env.ContainerRepository}}:${{env.ContainerImageTags}}" | |
| Write-Host "Pushing image $image" | |
| docker manifest create $image "${image}-linux-x64" "${image}-linux-arm64" | |
| docker manifest push "$image" |
This file contains hidden or 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
| <ContainerBaseImage>localhost:5000/test-base:latest-$(ContainerImageTagSuffix)</ContainerBaseImage> | |
| <ContainerImageTags>$(ContainerImageTags)-$(ContainerImageTagSuffix);latest-$(ContainerImageTagSuffix)</ContainerImageTags> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment