|
| 1 | +name: builds |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [ created ] |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} |
| 11 | + cancel-in-progress: true |
| 12 | +permissions: |
| 13 | + id-token: write # allows the JWT to be requested from GitHub's OIDC provider |
| 14 | + contents: read # This is required for actions/checkout |
| 15 | +env: |
| 16 | + arch_amd64: amd64 |
| 17 | + arch_arm64: arm64 |
| 18 | + docker_images_keydb: | |
| 19 | + name=rudderstack/rudder-keydb |
| 20 | + docker_tags_keydb: | |
| 21 | + type=ref,event=branch |
| 22 | + type=raw,value=${{ github.head_ref }},enable=${{ github.event_name == 'pull_request' }} |
| 23 | + type=raw,value=latest,enable=${{ github.event_name == 'release' }} |
| 24 | + type=semver,pattern={{version}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 25 | + type=semver,pattern={{major}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 26 | + type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 27 | + docker_images_keydb_operator: | |
| 28 | + name=rudderstack/rudder-keydb-operator |
| 29 | + docker_tags_keydb_operator: | |
| 30 | + type=ref,event=branch |
| 31 | + type=raw,value=${{ github.head_ref }},enable=${{ github.event_name == 'pull_request' }} |
| 32 | + type=raw,value=latest,enable=${{ github.event_name == 'release' }} |
| 33 | + type=semver,pattern={{version}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 34 | + type=semver,pattern={{major}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 35 | + type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} |
| 36 | +jobs: |
| 37 | + docker-meta-keydb: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + outputs: |
| 40 | + labels: ${{ steps.meta.outputs.labels }} |
| 41 | + build-date: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} |
| 42 | + version: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} |
| 43 | + revision: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} |
| 44 | + tags: ${{ steps.meta.outputs.tags }} |
| 45 | + arm64_tags: ${{ steps.arm64_meta.outputs.tags }} |
| 46 | + arm64_labels: ${{ steps.arm64_meta.outputs.labels }} |
| 47 | + amd64_tags: ${{ steps.amd64_meta.outputs.tags }} |
| 48 | + amd64_labels: ${{ steps.amd64_meta.outputs.labels }} |
| 49 | + steps: |
| 50 | + - name: Docker meta |
| 51 | + id: meta |
| 52 | + uses: docker/metadata-action@v5 |
| 53 | + with: |
| 54 | + images: ${{env.docker_images_keydb}} |
| 55 | + tags: ${{env.docker_tags_keydb}} |
| 56 | + - name: Docker arm64 meta |
| 57 | + id: arm64_meta |
| 58 | + uses: docker/metadata-action@v5 |
| 59 | + with: |
| 60 | + images: ${{env.docker_images_keydb}} |
| 61 | + tags: ${{env.docker_tags_keydb}} |
| 62 | + flavor: | |
| 63 | + suffix=-${{env.arch_arm64}},onlatest=true |
| 64 | + - name: Docker amd64 meta |
| 65 | + id: amd64_meta |
| 66 | + uses: docker/metadata-action@v5 |
| 67 | + with: |
| 68 | + images: ${{env.docker_images_keydb}} |
| 69 | + tags: ${{env.docker_tags_keydb}} |
| 70 | + flavor: | |
| 71 | + suffix=-${{env.arch_amd64}},onlatest=true |
| 72 | + docker-keydb: |
| 73 | + needs: |
| 74 | + - docker-meta-keydb |
| 75 | + strategy: |
| 76 | + matrix: |
| 77 | + build-config: |
| 78 | + - os: [ self-hosted, Linux, ARM64, ubuntu-22 ] |
| 79 | + tags: ${{needs.docker-meta-keydb.outputs.arm64_tags}} |
| 80 | + labels: ${{needs.docker-meta-keydb.outputs.arm64_labels}} |
| 81 | + platform: linux/arm64 |
| 82 | + - os: ubuntu-latest |
| 83 | + tags: ${{needs.docker-meta-keydb.outputs.amd64_tags}} |
| 84 | + labels: ${{needs.docker-meta-keydb.outputs.amd64_labels}} |
| 85 | + platform: linux/amd64 |
| 86 | + runs-on: ${{matrix.build-config.os}} |
| 87 | + steps: |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@v4 |
| 90 | + - name: Login to DockerHub |
| 91 | + uses: docker/login-action@v3 |
| 92 | + with: |
| 93 | + username: rudderlabs |
| 94 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 95 | + - name: Set up Docker Buildx |
| 96 | + uses: docker/setup-buildx-action@v3 |
| 97 | + - name: Build, scan and push |
| 98 | + uses: rudderlabs/[email protected] |
| 99 | + with: |
| 100 | + context: . |
| 101 | + platforms: ${{ matrix.build-config.platform }} |
| 102 | + push: true |
| 103 | + tags: ${{ matrix.build-config.tags }} |
| 104 | + labels: ${{ matrix.build-config.labels }} |
| 105 | + build-args: | |
| 106 | + BUILD_DATE=${{ needs.docker-meta-keydb.outputs.build-date }} |
| 107 | + VERSION=${{ needs.docker-meta-keydb.outputs.version }} |
| 108 | + COMMIT_HASH=${{ github.sha }} |
| 109 | + REVISION=${{ needs.docker-meta-keydb.outputs.revision }} |
| 110 | +
|
| 111 | + create-manifest: |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: [ docker-keydb, docker-meta-keydb ] |
| 114 | + steps: |
| 115 | + - name: Set up Docker Buildx |
| 116 | + uses: docker/setup-buildx-action@v3 |
| 117 | + - name: Login to DockerHub |
| 118 | + |
| 119 | + with: |
| 120 | + username: rudderlabs |
| 121 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 122 | + - name: Create multi-arch manifest for Docker |
| 123 | + run: | |
| 124 | + while read -r tag; do |
| 125 | + echo "$tag" |
| 126 | + arm_tag=$(echo "${{ needs.docker-meta-keydb.outputs.arm64_tags }}" | grep "$tag") |
| 127 | + echo "$arm_tag" |
| 128 | + amd_tag=$(echo "${{ needs.docker-meta-keydb.outputs.amd64_tags }}" | grep "$tag") |
| 129 | + echo "$amd_tag" |
| 130 | + docker buildx imagetools create -t $tag $arm_tag $amd_tag |
| 131 | + done <<< "${{ needs.docker-meta-keydb.outputs.tags }}" |
| 132 | +
|
| 133 | + docker-meta-keydb-operator: |
| 134 | + runs-on: ubuntu-latest |
| 135 | + outputs: |
| 136 | + labels: ${{ steps.meta.outputs.labels }} |
| 137 | + build-date: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} |
| 138 | + version: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} |
| 139 | + revision: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} |
| 140 | + tags: ${{ steps.meta.outputs.tags }} |
| 141 | + arm64_tags: ${{ steps.arm64_meta.outputs.tags }} |
| 142 | + arm64_labels: ${{ steps.arm64_meta.outputs.labels }} |
| 143 | + amd64_tags: ${{ steps.amd64_meta.outputs.tags }} |
| 144 | + amd64_labels: ${{ steps.amd64_meta.outputs.labels }} |
| 145 | + steps: |
| 146 | + - name: Docker meta |
| 147 | + id: meta |
| 148 | + uses: docker/metadata-action@v5 |
| 149 | + with: |
| 150 | + images: ${{env.docker_images_keydb_operator}} |
| 151 | + tags: ${{env.docker_tags_keydb_operator}} |
| 152 | + - name: Docker arm64 meta |
| 153 | + id: arm64_meta |
| 154 | + uses: docker/metadata-action@v5 |
| 155 | + with: |
| 156 | + images: ${{env.docker_images_keydb_operator}} |
| 157 | + tags: ${{env.docker_tags_keydb_operator}} |
| 158 | + flavor: | |
| 159 | + suffix=-${{env.arch_arm64}},onlatest=true |
| 160 | + - name: Docker amd64 meta |
| 161 | + id: amd64_meta |
| 162 | + uses: docker/metadata-action@v5 |
| 163 | + with: |
| 164 | + images: ${{env.docker_images_keydb_operator}} |
| 165 | + tags: ${{env.docker_tags_keydb_operator}} |
| 166 | + flavor: | |
| 167 | + suffix=-${{env.arch_amd64}},onlatest=true |
| 168 | + docker-keydb-operator: |
| 169 | + needs: |
| 170 | + - docker-meta-keydb-operator |
| 171 | + strategy: |
| 172 | + matrix: |
| 173 | + build-config: |
| 174 | + - os: [ self-hosted, Linux, ARM64, ubuntu-22 ] |
| 175 | + tags: ${{needs.docker-meta-keydb-operator.outputs.arm64_tags}} |
| 176 | + labels: ${{needs.docker-meta-keydb-operator.outputs.arm64_labels}} |
| 177 | + platform: linux/arm64 |
| 178 | + - os: ubuntu-latest |
| 179 | + tags: ${{needs.docker-meta-keydb-operator.outputs.amd64_tags}} |
| 180 | + labels: ${{needs.docker-meta-keydb-operator.outputs.amd64_labels}} |
| 181 | + platform: linux/amd64 |
| 182 | + runs-on: ${{matrix.build-config.os}} |
| 183 | + steps: |
| 184 | + - name: Checkout |
| 185 | + uses: actions/checkout@v4 |
| 186 | + - name: Login to DockerHub |
| 187 | + uses: docker/login-action@v3 |
| 188 | + with: |
| 189 | + username: rudderlabs |
| 190 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 191 | + - name: Set up Docker Buildx |
| 192 | + uses: docker/setup-buildx-action@v3 |
| 193 | + - name: Build, scan and push |
| 194 | + uses: rudderlabs/[email protected] |
| 195 | + with: |
| 196 | + context: . |
| 197 | + platforms: ${{ matrix.build-config.platform }} |
| 198 | + push: true |
| 199 | + tags: ${{ matrix.build-config.tags }} |
| 200 | + labels: ${{ matrix.build-config.labels }} |
| 201 | + build-args: | |
| 202 | + BUILD_DATE=${{ needs.docker-meta-keydb-operator.outputs.build-date }} |
| 203 | + VERSION=${{ needs.docker-meta-keydb-operator.outputs.version }} |
| 204 | + COMMIT_HASH=${{ github.sha }} |
| 205 | + REVISION=${{ needs.docker-meta-keydb-operator.outputs.revision }} |
| 206 | +
|
| 207 | + create-manifest-keydb-operator: |
| 208 | + runs-on: ubuntu-latest |
| 209 | + needs: [ docker-keydb-operator, docker-meta-keydb-operator ] |
| 210 | + steps: |
| 211 | + - name: Set up Docker Buildx |
| 212 | + uses: docker/setup-buildx-action@v3 |
| 213 | + - name: Login to DockerHub |
| 214 | + |
| 215 | + with: |
| 216 | + username: rudderlabs |
| 217 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 218 | + - name: Create multi-arch manifest for Docker |
| 219 | + run: | |
| 220 | + while read -r tag; do |
| 221 | + echo "$tag" |
| 222 | + arm_tag=$(echo "${{ needs.docker-meta-keydb-operator.outputs.arm64_tags }}" | grep "$tag") |
| 223 | + echo "$arm_tag" |
| 224 | + amd_tag=$(echo "${{ needs.docker-meta-keydb-operator.outputs.amd64_tags }}" | grep "$tag") |
| 225 | + echo "$amd_tag" |
| 226 | + docker buildx imagetools create -t $tag $arm_tag $amd_tag |
| 227 | + done <<< "${{ needs.docker-meta-keydb-operator.outputs.tags }}" |
0 commit comments