|
| 1 | +name: multiarch2 |
| 2 | + |
| 3 | +on: |
| 4 | + # push: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY_IMAGE: mwader/static-ffmpeg:test- |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - runs_on: ubicloud-standard-8-arm |
| 16 | + tag: arm64 |
| 17 | + - runs_on: ubuntu-latest |
| 18 | + tag: amd64 |
| 19 | + |
| 20 | + runs-on: ${{ matrix.runs_on }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + - name: Docker build |
| 24 | + run: docker build --tag image:${{ matrix.tag }} . |
| 25 | + - name: Docker save |
| 26 | + run: docker image save --output image-${{ matrix.tag }}.tar image:${{ matrix.tag }} |
| 27 | + - name: Upload Docker image-${{ matrix.tag }} |
| 28 | + uses: actions/upload-artifact@v4 |
| 29 | + with: |
| 30 | + name: image-${{ matrix.tag }} |
| 31 | + path: image-${{ matrix.tag }}.tar |
| 32 | + retention-days: 1 |
| 33 | + |
| 34 | + tag: |
| 35 | + name: Extract tag name |
| 36 | + runs-on: ubuntu-latest |
| 37 | + outputs: |
| 38 | + TAG: ${{ steps.tag.outputs.result }} |
| 39 | + steps: |
| 40 | + - name: Extract the tag name |
| 41 | + id: tag |
| 42 | + uses: actions/github-script@0.2.0 |
| 43 | + with: |
| 44 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + script: | |
| 46 | + return context.payload.ref === "refs/heads/master" |
| 47 | + ? 'latest' |
| 48 | + : context.payload.ref.replace(/^refs\/(tags|heads)\//, ''); |
| 49 | +
|
| 50 | + merge: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: |
| 53 | + - build |
| 54 | + - tag |
| 55 | + steps: |
| 56 | + - name: Download digests |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + path: /tmp |
| 60 | + pattern: image-* |
| 61 | + merge-multiple: true |
| 62 | + - name: Load Docker images |
| 63 | + run: | |
| 64 | + docker image load --input /tmp/image-arm64.tar |
| 65 | + docker image load --input /tmp/image-amd64.tar |
| 66 | + - name: Docker meta |
| 67 | + id: meta |
| 68 | + uses: docker/metadata-action@v5 |
| 69 | + with: |
| 70 | + images: ${{ env.REGISTRY_IMAGE }} |
| 71 | + - name: Login to Docker Hub |
| 72 | + uses: docker/login-action@v3 |
| 73 | + with: |
| 74 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 75 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 76 | + - name: Create manifest list and push |
| 77 | + run: | |
| 78 | + docker manifest create \ |
| 79 | + ${{ env.REGISTRY_IMAGE }}${{ needs.tag.outputs.TAG }} \ |
| 80 | + --amend image:arm64 \ |
| 81 | + --amend image:amd64 |
| 82 | + docker manifest inspect ${{ env.REGISTRY_IMAGE }}${{ needs.tag.outputs.TAG }} |
| 83 | + docker manifest push ${{ env.REGISTRY_IMAGE }}${{ needs.tag.outputs.TAG }} |
| 84 | + - name: Inspect image |
| 85 | + run: | |
| 86 | + docker buildx imagetools inspect {{ $env.REGISTRY_IMAGE }}${{ needs.tag.outputs.TAG }} |
0 commit comments