|
| 1 | +name: Release Publish |
| 2 | +on: workflow_dispatch |
| 3 | + |
| 4 | +jobs: |
| 5 | + build-context: |
| 6 | + runs-on: ubuntu-latest |
| 7 | + steps: |
| 8 | + - name: Dump GitHub context |
| 9 | + env: |
| 10 | + GITHUB_CONTEXT: ${{ toJson(github) }} |
| 11 | + run: echo "$GITHUB_CONTEXT" |
| 12 | + build: |
| 13 | + needs: build-context |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - runner: ubuntu-latest |
| 18 | + platform: linux/amd64 |
| 19 | + arch_alias: 'amd64' |
| 20 | + - runner: ubuntu-latest-arm64 |
| 21 | + platform: linux/arm64 |
| 22 | + arch_alias: 'arm64' |
| 23 | + runs-on: ${{ matrix.runner }} |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Env seen prerun |
| 29 | + run: env |
| 30 | + |
| 31 | + - name: Get branch metadata |
| 32 | + id: branch-name |
| 33 | + uses: tj-actions/branch-names@v8 |
| 34 | + |
| 35 | + - name: Current tag name |
| 36 | + run: | |
| 37 | + echo "Tag if exist: ${{ steps.branch-name.outputs.tag }}" |
| 38 | +
|
| 39 | + - name: If not a tag, terminate the workflow |
| 40 | + if: steps.branch-name.outputs.is_tag != 'true' |
| 41 | + run: exit 1 |
| 42 | + |
| 43 | + - name: Running on a tag. |
| 44 | + run: | |
| 45 | + echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV} |
| 46 | + echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" > tag_name.txt |
| 47 | +
|
| 48 | + # Archive the tag name |
| 49 | + - name: Archive tag name |
| 50 | + uses: actions/upload-artifact@v2 |
| 51 | + with: |
| 52 | + name: tag_name |
| 53 | + path: tag_name.txt |
| 54 | + |
| 55 | + # setup Docker build action |
| 56 | + - name: Set up Docker Buildx |
| 57 | + id: buildx |
| 58 | + uses: docker/setup-buildx-action@v3 |
| 59 | + - name: Set up QEMU |
| 60 | + id: qemu |
| 61 | + uses: docker/setup-qemu-action@v3 |
| 62 | + |
| 63 | + - name: Login to DockerHub |
| 64 | + uses: docker/login-action@v3 |
| 65 | + with: |
| 66 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 67 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Build crapi-identity all platforms and push to Docker Hub |
| 70 | + uses: docker/build-push-action@v3 |
| 71 | + with: |
| 72 | + context: ./services/identity |
| 73 | + tags: crapi/crapi-identity:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 74 | + platforms: ${{ matrix.platform }} |
| 75 | + push: true |
| 76 | + cache-from: type=gha,scope=identity-service |
| 77 | + cache-to: type=gha,mode=max,scope=identity-service |
| 78 | + |
| 79 | + - name: Build crapi-workshop all platforms and push to Docker Hub |
| 80 | + uses: docker/build-push-action@v3 |
| 81 | + with: |
| 82 | + context: ./services/workshop |
| 83 | + tags: crapi/crapi-workshop:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 84 | + platforms: ${{ matrix.platform }} |
| 85 | + push: true |
| 86 | + cache-from: type=gha,scope=workshop-service |
| 87 | + cache-to: type=gha,mode=max,scope=workshop-service |
| 88 | + |
| 89 | + - name: Build crapi-chatbot all platforms and push to Docker Hub |
| 90 | + uses: docker/build-push-action@v3 |
| 91 | + with: |
| 92 | + context: ./services/chatbot |
| 93 | + tags: crapi/crapi-chatbot:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 94 | + platforms: ${{ matrix.platform }} |
| 95 | + push: true |
| 96 | + cache-from: type=gha,scope=chatbot-service |
| 97 | + cache-to: type=gha,mode=max,scope=chatbot-service |
| 98 | + |
| 99 | + - name: Build crapi-community all platforms and push to Docker Hub |
| 100 | + uses: docker/build-push-action@v3 |
| 101 | + with: |
| 102 | + context: ./services/community |
| 103 | + tags: crapi/crapi-community:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 104 | + platforms: ${{ matrix.platform }} |
| 105 | + push: true |
| 106 | + cache-from: type=gha,scope=community-service |
| 107 | + cache-to: type=gha,mode=max,scope=community-service |
| 108 | + |
| 109 | + - name: Build crapi-web all platforms and push to Docker Hub |
| 110 | + uses: docker/build-push-action@v3 |
| 111 | + with: |
| 112 | + context: ./services/web |
| 113 | + tags: crapi/crapi-web:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 114 | + platforms: ${{ matrix.platform }} |
| 115 | + push: true |
| 116 | + cache-from: type=gha,scope=web-service |
| 117 | + cache-to: type=gha,mode=max,scope=web-service |
| 118 | + |
| 119 | + - name: Build gateway-service all platforms and push to Docker Hub |
| 120 | + uses: docker/build-push-action@v3 |
| 121 | + with: |
| 122 | + context: ./services/gateway-service |
| 123 | + tags: crapi/gateway-service:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 124 | + platforms: ${{ matrix.platform }} |
| 125 | + push: true |
| 126 | + cache-from: type=gha,scope=gateway-service |
| 127 | + cache-to: type=gha,mode=max,scope=gateway-service |
| 128 | + |
| 129 | + - name: Build mailhog all platforms and push to Docker Hub |
| 130 | + uses: docker/build-push-action@v3 |
| 131 | + with: |
| 132 | + context: ./services/mailhog |
| 133 | + tags: crapi/mailhog:${{ env.TAG_NAME }}-${{ matrix.arch_alias }} |
| 134 | + platforms: ${{ matrix.platform }} |
| 135 | + push: true |
| 136 | + cache-from: type=gha,scope=mailhog-service |
| 137 | + cache-to: type=gha,mode=max,scope=mailhog-service |
| 138 | + |
| 139 | + publish-manifests: |
| 140 | + needs: build |
| 141 | + runs-on: ubuntu-latest |
| 142 | + steps: |
| 143 | + - name: Checkout code |
| 144 | + uses: actions/checkout@v4 |
| 145 | + |
| 146 | + - name: Download tag name |
| 147 | + uses: actions/download-artifact@v2 |
| 148 | + with: |
| 149 | + name: tag_name |
| 150 | + path: . |
| 151 | + |
| 152 | + - name: Read tag name |
| 153 | + id: tag_name |
| 154 | + run: | |
| 155 | + echo "TAG_NAME=$(cat tag_name.txt)" >> $GITHUB_ENV |
| 156 | +
|
| 157 | + - name: Create and push manifest images for crapi-identity |
| 158 | + uses: Noelware/docker-manifest-action@v1 |
| 159 | + with: |
| 160 | + inputs: | |
| 161 | + crapi/crapi-identity:${{ env.TAG_NAME }}-amd64 |
| 162 | + crapi/crapi-identity:${{ env.TAG_NAME }}-arm64 |
| 163 | + outputs: | |
| 164 | + crapi/crapi-identity:${{ env.TAG_NAME }} |
| 165 | + push: true |
| 166 | + |
| 167 | + - name: Create and push manifest images for crapi-workshop |
| 168 | + uses: Noelware/docker-manifest-action@v1 |
| 169 | + with: |
| 170 | + inputs: | |
| 171 | + crapi/crapi-workshop:${{ env.TAG_NAME }}-amd64 |
| 172 | + crapi/crapi-workshop:${{ env.TAG_NAME }}-arm64 |
| 173 | + outputs: | |
| 174 | + crapi/crapi-workshop:${{ env.TAG_NAME }} |
| 175 | + push: true |
| 176 | + |
| 177 | + - name: Create and push manifest images for crapi-chatbot |
| 178 | + uses: Noelware/docker-manifest-action@v1 |
| 179 | + with: |
| 180 | + inputs: | |
| 181 | + crapi/crapi-chatbot:${{ env.TAG_NAME }}-amd64 |
| 182 | + crapi/crapi-chatbot:${{ env.TAG_NAME }}-arm64 |
| 183 | + outputs: | |
| 184 | + crapi/crapi-chatbot:${{ env.TAG_NAME }} |
| 185 | + push: true |
| 186 | + |
| 187 | + - name: Create and push manifest images for crapi-community |
| 188 | + uses: Noelware/docker-manifest-action@v1 |
| 189 | + with: |
| 190 | + inputs: | |
| 191 | + crapi/crapi-community:${{ env.TAG_NAME }}-amd64 |
| 192 | + crapi/crapi-community:${{ env.TAG_NAME }}-arm64 |
| 193 | + outputs: | |
| 194 | + crapi/crapi-community:${{ env.TAG_NAME }} |
| 195 | + push: true |
| 196 | + |
| 197 | + - name: Create and push manifest images for crapi-web |
| 198 | + uses: Noelware/docker-manifest-action@v1 |
| 199 | + with: |
| 200 | + inputs: | |
| 201 | + crapi/crapi-web:${{ env.TAG_NAME }}-amd64 |
| 202 | + crapi/crapi-web:${{ env.TAG_NAME }}-arm64 |
| 203 | + outputs: | |
| 204 | + crapi/crapi-web:${{ env.TAG_NAME }} |
| 205 | + push: true |
| 206 | + |
| 207 | + - name: Create and push manifest images for gateway-service |
| 208 | + uses: Noelware/docker-manifest-action@v1 |
| 209 | + with: |
| 210 | + inputs: | |
| 211 | + crapi/gateway-service:${{ env.TAG_NAME }}-amd64 |
| 212 | + crapi/gateway-service:${{ env.TAG_NAME }}-arm64 |
| 213 | + outputs: | |
| 214 | + crapi/gateway-service:${{ env.TAG_NAME }} |
| 215 | + push: true |
| 216 | + |
| 217 | + - name: Create and push manifest images for mailhog |
| 218 | + uses: Noelware/docker-manifest-action@v1 |
| 219 | + with: |
| 220 | + inputs: | |
| 221 | + crapi/mailhog:${{ env.TAG_NAME }}-amd64 |
| 222 | + crapi/mailhog:${{ env.TAG_NAME }}-arm64 |
| 223 | + outputs: | |
| 224 | + crapi/mailhog:${{ env.TAG_NAME }} |
| 225 | + push: true |
0 commit comments