Upgrade container to OpenHPC 4.x/Rocky 10 #63
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: Build and Publish Container | |
| on: | |
| push: | |
| branches: | |
| - 3.x | |
| - 4.x | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-arch: | |
| runs-on: ${{ matrix.runs-on }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| arch: [ x86_64, aarch64 ] | |
| include: | |
| - arch: x86_64 | |
| runs-on: ubuntu-24.04 | |
| - arch: aarch64 | |
| runs-on: ubuntu-24.04-arm | |
| outputs: | |
| digest-x86_64: ${{ steps.export.outputs.digest-x86_64 }} | |
| digest-aarch64: ${{ steps.export.outputs.digest-aarch64 }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./containers | |
| file: ./containers/container/Containerfile | |
| platforms: linux/${{ matrix.arch }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: false # Disable provenance to avoid unknown/unknown | |
| sbom: false # Disable sbom to avoid unknown/unknown | |
| build-args: | | |
| ARCH=${{ matrix.arch }} | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Export digest | |
| id: export | |
| run: | | |
| echo "digest-${{ matrix.arch }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| needs: build-arch | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push manifest | |
| run: | | |
| # Create manifest list for each tag | |
| TAGS="${{ steps.meta.outputs.tags }}" | |
| for tag in $TAGS; do | |
| docker buildx imagetools create \ | |
| --tag $tag \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-arch.outputs.digest-x86_64 }} \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-arch.outputs.digest-aarch64 }} | |
| done |