ci: fix moltis workflow context path #2
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 & Publish Moltis multi-arch image to GHCR | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| paths: | |
| - 'vendor/moltis/**' | |
| - '.github/workflows/build-docker-moltis.yml' | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: 'Docker image tag (default: latest)' | |
| required: false | |
| default: 'latest' | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-moltis | |
| jobs: | |
| prepare: | |
| name: Prepare tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.tag.outputs.tag }} | |
| steps: | |
| - name: Resolve image tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.image_tag }}" ]; then | |
| TAG="${{ github.event.inputs.image_tag }}" | |
| else | |
| TAG="latest" | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Using image tag: $TAG" | |
| build-amd64: | |
| name: Build AMD64 image | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build & push AMD64 image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.moltis | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.tag }}-amd64 | |
| cache-from: type=gha,scope=moltis-amd64 | |
| cache-to: type=gha,mode=max,scope=moltis-amd64 | |
| build-arm64: | |
| name: Build ARM64 image | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build & push ARM64 image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.moltis | |
| platforms: linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.tag }}-arm64 | |
| cache-from: type=gha,scope=moltis-arm64 | |
| cache-to: type=gha,mode=max,scope=moltis-arm64 | |
| create-manifest: | |
| name: Create multi-arch manifest | |
| needs: [prepare, build-amd64, build-arm64] | |
| if: always() && needs.build-amd64.result == 'success' && needs.build-arm64.result == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push multi-arch manifest | |
| run: | | |
| TAG="${{ needs.prepare.outputs.tag }}" | |
| IMAGE="${{ env.IMAGE_NAME }}" | |
| docker buildx imagetools create \ | |
| --tag "${IMAGE}:${TAG}" \ | |
| "${IMAGE}:${TAG}-amd64" \ | |
| "${IMAGE}:${TAG}-arm64" | |
| echo "Created manifest: ${IMAGE}:${TAG}" |