Publish Containers #13
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
| name: Publish Containers | |
| on: workflow_dispatch | |
| jobs: | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-24.04 | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| WEB_PROJECT_PATH: src/Buttercup.Web | |
| permissions: | |
| attestations: write | |
| id-token: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.1xx | |
| dotnet-quality: ga | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| cache-dependency-path: ${{env.WEB_PROJECT_PATH}}/package-lock.json | |
| - name: Restore Node.js dependencies | |
| run: npm ci | |
| working-directory: ${{env.WEB_PROJECT_PATH}} | |
| - name: Build assets | |
| run: npx gulp build | |
| working-directory: ${{env.WEB_PROJECT_PATH}} | |
| - name: Build architecture-specific images | |
| run: | | |
| dotnet publish Buttercup.Web.csproj \ | |
| -t PublishContainer \ | |
| -p ContainerFamily=noble-chiseled-extra \ | |
| -p ContainerRepository=$IMAGE_NAME \ | |
| -p RuntimeIdentifiers='"linux-x64;linux-arm64"' \ | |
| -p LocalRegistry=Podman | |
| working-directory: ${{env.WEB_PROJECT_PATH}} | |
| - name: Build multi-architecture image | |
| run: | | |
| podman manifest create $IMAGE_NAME:latest | |
| podman manifest add $IMAGE_NAME:latest containers-storage:localhost/$IMAGE_NAME:latest-linux-arm64 | |
| podman manifest add $IMAGE_NAME:latest containers-storage:localhost/$IMAGE_NAME:latest-linux-x64 | |
| - name: Log in to container registry | |
| uses: redhat-actions/podman-login@v1 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push to container registry | |
| id: push | |
| run: | | |
| podman push $IMAGE_NAME:latest-linux-arm64 docker://$REGISTRY/$IMAGE_NAME:commit-$GITHUB_SHA-linux-arm64 | |
| podman push $IMAGE_NAME:latest-linux-arm64 docker://$REGISTRY/$IMAGE_NAME:latest-linux-arm64 --digestfile digest | |
| echo "arm64-digest=$(cat digest)" >> "$GITHUB_OUTPUT" | |
| podman push $IMAGE_NAME:latest-linux-x64 docker://$REGISTRY/$IMAGE_NAME:commit-$GITHUB_SHA-linux-x64 | |
| podman push $IMAGE_NAME:latest-linux-x64 docker://$REGISTRY/$IMAGE_NAME:latest-linux-x64 --digestfile digest | |
| echo "x64-digest=$(cat digest)" >> "$GITHUB_OUTPUT" | |
| podman manifest push $IMAGE_NAME:latest docker://$REGISTRY/$IMAGE_NAME:commit-$GITHUB_SHA | |
| podman manifest push $IMAGE_NAME:latest docker://$REGISTRY/$IMAGE_NAME:latest --digestfile digest | |
| echo "multi-arch-digest=$(cat digest)" >> "$GITHUB_OUTPUT" | |
| - name: Attest arm64 image | |
| uses: actions/attest@v4 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.push.outputs.arm64-digest }} | |
| - name: Attest x64 image | |
| uses: actions/attest@v4 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.push.outputs.x64-digest }} | |
| - name: Attest multi-architecture image | |
| uses: actions/attest@v4 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.push.outputs.multi-arch-digest }} |