|
9 | 9 | env: |
10 | 10 | GOPATH: /home/runner/go/ |
11 | 11 | GOPROXY: "https://proxy.golang.org" |
| 12 | + REGISTRY_IMAGE: pluralsh/deployment-operator |
12 | 13 | jobs: |
13 | 14 | build: |
14 | 15 | name: Build |
@@ -42,59 +43,114 @@ jobs: |
42 | 43 | - uses: golangci/golangci-lint-action@v6 |
43 | 44 | with: |
44 | 45 | version: v1.63.4 |
45 | | - publish: |
46 | | - name: Build and push Agent container |
47 | | - runs-on: ubuntu-20.04 |
48 | | - needs: |
49 | | - - test |
| 46 | + build-image: |
| 47 | + name: Build image |
| 48 | + needs: [build, test] |
50 | 49 | permissions: |
51 | 50 | contents: 'read' |
52 | 51 | id-token: 'write' |
53 | 52 | packages: 'write' |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: |
| 56 | + platforms: |
| 57 | + - platform: linux/amd64 |
| 58 | + runner: ubuntu-24.04 |
| 59 | + - platform: linux/arm64 |
| 60 | + runner: ubuntu-24.04-arm |
| 61 | + runs-on: ${{ matrix.platforms.runner }} |
54 | 62 | steps: |
55 | | - - name: Checkout |
56 | | - uses: actions/checkout@v4 |
57 | | - with: |
58 | | - fetch-depth: 0 |
59 | | - - name: Docker meta |
60 | | - id: meta |
61 | | - uses: docker/metadata-action@v5 |
62 | | - with: |
63 | | - # list of Docker images to use as base name for tags |
64 | | - images: | |
65 | | - ghcr.io/pluralsh/deployment-operator |
66 | | - docker.io/pluralsh/deployment-operator |
67 | | - # generate Docker tags based on the following events/attributes |
68 | | - tags: | |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + fetch-depth: 0 |
| 67 | + - name: Prepare |
| 68 | + run: | |
| 69 | + platform=${{ matrix.platforms.platform }} |
| 70 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 71 | + - name: Docker meta |
| 72 | + id: meta |
| 73 | + uses: docker/metadata-action@v5 |
| 74 | + with: |
| 75 | + images: ${{ env.REGISTRY_IMAGE }} |
| 76 | + - name: Set up QEMU |
| 77 | + uses: docker/setup-qemu-action@v3 |
| 78 | + - name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@v3 |
| 80 | + - name: Login to Docker Hub |
| 81 | + uses: docker/login-action@v3 |
| 82 | + with: |
| 83 | + username: mjgpluralsh |
| 84 | + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
| 85 | + - name: Build and push by digest |
| 86 | + id: build |
| 87 | + uses: docker/build-push-action@v6 |
| 88 | + with: |
| 89 | + context: "." |
| 90 | + file: "./Dockerfile" |
| 91 | + tags: ${{ env.REGISTRY_IMAGE }} |
| 92 | + labels: ${{ steps.meta.outputs.labels }} |
| 93 | + platforms: ${{ matrix.platforms.platform }} |
| 94 | + outputs: type=image,push-by-digest=true,name-canonical=true,push=true |
| 95 | + cache-from: type=gha |
| 96 | + cache-to: type=gha,mode=max |
| 97 | + build-args: | |
| 98 | + GIT_COMMIT=${{ github.sha }} |
| 99 | + - name: Export digest |
| 100 | + run: | |
| 101 | + mkdir -p ${{ runner.temp }}/digests |
| 102 | + digest="${{ steps.build.outputs.digest }}" |
| 103 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 104 | + - name: Upload digest |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + with: |
| 107 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 108 | + path: ${{ runner.temp }}/digests/* |
| 109 | + if-no-files-found: error |
| 110 | + retention-days: 1 |
| 111 | + publish-image: |
| 112 | + name: Publish image |
| 113 | + needs: [build-image] |
| 114 | + strategy: |
| 115 | + fail-fast: false |
| 116 | + matrix: |
| 117 | + images: [ "ghcr.io/pluralsh/deployment-operator", "docker.io/pluralsh/deployment-operator" ] |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - name: Download digests |
| 121 | + uses: actions/download-artifact@v4 |
| 122 | + with: |
| 123 | + path: ${{ runner.temp }}/digests |
| 124 | + pattern: digests-* |
| 125 | + merge-multiple: true |
| 126 | + - name: Login to GHCR |
| 127 | + uses: docker/login-action@v3 |
| 128 | + with: |
| 129 | + registry: ghcr.io |
| 130 | + username: ${{ github.repository_owner }} |
| 131 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + - name: Login to Docker Hub |
| 133 | + uses: docker/login-action@v3 |
| 134 | + with: |
| 135 | + username: mjgpluralsh |
| 136 | + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
| 137 | + - name: Set up Docker Buildx |
| 138 | + uses: docker/setup-buildx-action@v3 |
| 139 | + - name: Docker meta |
| 140 | + id: meta |
| 141 | + uses: docker/metadata-action@v5 |
| 142 | + with: |
| 143 | + images: ${{ matrix.images }} |
| 144 | + tags: | |
69 | 145 | type=sha |
70 | 146 | type=ref,event=pr |
71 | 147 | type=ref,event=branch |
72 | 148 | type=semver,pattern={{version}},value=${{ needs.prepare.outputs.new_release_version }} |
73 | | - - name: Set up QEMU |
74 | | - uses: docker/setup-qemu-action@v3 |
75 | | - - name: Set up Docker Buildx |
76 | | - uses: docker/setup-buildx-action@v3 |
77 | | - - name: Login to GHCR |
78 | | - uses: docker/login-action@v3 |
79 | | - with: |
80 | | - registry: ghcr.io |
81 | | - username: ${{ github.repository_owner }} |
82 | | - password: ${{ secrets.GITHUB_TOKEN }} |
83 | | - - name: Login to Docker |
84 | | - uses: docker/login-action@v3 |
85 | | - with: |
86 | | - username: mjgpluralsh |
87 | | - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
88 | | - - name: Build and push |
89 | | - uses: docker/build-push-action@v5 |
90 | | - with: |
91 | | - context: "." |
92 | | - file: "./Dockerfile" |
93 | | - push: true |
94 | | - tags: ${{ steps.meta.outputs.tags }} |
95 | | - labels: ${{ steps.meta.outputs.labels }} |
96 | | - platforms: linux/amd64,linux/arm64 |
97 | | - cache-from: type=gha |
98 | | - cache-to: type=gha,mode=max |
99 | | - build-args: | |
100 | | - GIT_COMMIT=${{ github.sha }} |
| 149 | + - name: Create manifest list and push |
| 150 | + working-directory: ${{ runner.temp }}/digests |
| 151 | + run: | |
| 152 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 153 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 154 | + - name: Inspect image |
| 155 | + run: | |
| 156 | + docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }} |
0 commit comments