|
| 1 | +name: Publish Test-Suite Image |
| 2 | +run-name: Publish Test-Suite ${{ inputs.tag || github.event.release.tag_name }} Image |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: "Image tag" |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + platforms: |
| 14 | + description: "Platforms - Comma separated list of the platforms to support." |
| 15 | + required: true |
| 16 | + default: linux/amd64 |
| 17 | + type: string |
| 18 | + ref: |
| 19 | + description: "Optional - The branch, tag or SHA to checkout." |
| 20 | + required: false |
| 21 | + type: string |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + packages: write |
| 26 | + |
| 27 | +env: |
| 28 | + PLATFORMS: ${{ inputs.platforms || 'linux/amd64,linux/arm64' }} |
| 29 | + |
| 30 | +jobs: |
| 31 | + publish-image: |
| 32 | + if: github.repository_owner == 'w3c' |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + |
| 36 | + name: Publish Test-Suite Image |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Checkout Code |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + ref: ${{ inputs.ref || '' }} |
| 43 | + |
| 44 | + - name: Gather image info |
| 45 | + id: info |
| 46 | + run: | |
| 47 | + echo "repo-owner=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Cache Docker layers |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: /tmp/.buildx-cache |
| 53 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-buildx- |
| 56 | +
|
| 57 | + - name: Set up Docker Buildx |
| 58 | + uses: docker/setup-buildx-action@v3 |
| 59 | + |
| 60 | + - name: Log in to the GitHub Container Registry |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + registry: ghcr.io |
| 64 | + username: ${{ github.repository_owner }} |
| 65 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + |
| 67 | + - name: Setup Image Metadata |
| 68 | + id: meta |
| 69 | + uses: docker/metadata-action@v5 |
| 70 | + with: |
| 71 | + images: | |
| 72 | + ghcr.io/${{ steps.info.outputs.repo-owner }}/vc-data-model-2.0-test-suite |
| 73 | + tags: | |
| 74 | + type=raw,value=${{ inputs.tag || github.event.release.tag_name }} |
| 75 | +
|
| 76 | + - name: Build and Push Image to ghcr.io |
| 77 | + uses: docker/build-push-action@v6 |
| 78 | + with: |
| 79 | + push: true |
| 80 | + context: . |
| 81 | + tags: ${{ steps.meta.outputs.tags }} |
| 82 | + labels: ${{ steps.meta.outputs.labels }} |
| 83 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 84 | + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max |
| 85 | + platforms: ${{ env.PLATFORMS }} |
| 86 | + |
| 87 | + # Temp fix |
| 88 | + # https://github.com/docker/build-push-action/issues/252 |
| 89 | + # https://github.com/moby/buildkit/issues/1896 |
| 90 | + - name: Move cache |
| 91 | + run: | |
| 92 | + rm -rf /tmp/.buildx-cache |
| 93 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments