split images to seperate jobs #3
Workflow file for this run
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: Docker | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| metadata: | |
| runs-on: tec-runners | |
| permissions: | |
| contents: read | |
| outputs: | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/notwedtm/leader-stream | |
| tags: | | |
| type=sha,format=long | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| build-amd64: | |
| runs-on: tec-runners | |
| needs: metadata | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| 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 | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Derive amd64 tags | |
| id: tags | |
| run: | | |
| set -euo pipefail | |
| tags="${{ needs.metadata.outputs.tags }}" | |
| if [ -z "$tags" ]; then | |
| echo "No tags produced by metadata action" >&2 | |
| exit 1 | |
| fi | |
| echo "tags<<'EOF'" >> "$GITHUB_OUTPUT" | |
| echo "$tags" | tr ',' '\n' | sed 's/$/-amd64/' >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Build and push (amd64) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: ${{ github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }} | |
| tags: ${{ steps.tags.outputs.tags }} | |
| labels: ${{ needs.metadata.outputs.labels }} | |
| build-arm64: | |
| runs-on: tec-runners | |
| needs: metadata | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| 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 | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Derive arm64 tags | |
| id: tags | |
| run: | | |
| set -euo pipefail | |
| tags="${{ needs.metadata.outputs.tags }}" | |
| if [ -z "$tags" ]; then | |
| echo "No tags produced by metadata action" >&2 | |
| exit 1 | |
| fi | |
| echo "tags<<'EOF'" >> "$GITHUB_OUTPUT" | |
| echo "$tags" | tr ',' '\n' | sed 's/$/-arm64/' >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Build and push (arm64) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: ${{ github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) }} | |
| tags: ${{ steps.tags.outputs.tags }} | |
| labels: ${{ needs.metadata.outputs.labels }} | |
| manifest: | |
| runs-on: tec-runners | |
| needs: [metadata, build-amd64, build-arm64] | |
| if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - 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: Create multi-arch manifests | |
| run: | | |
| set -euo pipefail | |
| tags="${{ needs.metadata.outputs.tags }}" | |
| if [ -z "$tags" ]; then | |
| echo "No tags produced by metadata action" >&2 | |
| exit 1 | |
| fi | |
| echo "$tags" | tr ',' '\n' | while read -r tag; do | |
| if [ -z "$tag" ]; then | |
| continue | |
| fi | |
| docker buildx imagetools create \ | |
| -t "$tag" \ | |
| "${tag}-amd64" \ | |
| "${tag}-arm64" | |
| done |