[workflows] Add Go bot image pipeline to game workflow (#201) #234
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "game build, push" | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| paths: | |
| - ".github/workflows/**" | |
| - "bots/**" | |
| - "server/**" | |
| tags: | |
| - "v*" | |
| pull_request: | |
| paths: | |
| - ".github/workflows/**" | |
| - "bots/**" | |
| - "server/**" | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| SERVER_IMAGE: ghcr.io/${{ github.repository_owner }}/server | |
| BOT_C_IMAGE: ghcr.io/${{ github.repository_owner }}/my-core-bot-c | |
| BOT_TS_IMAGE: ghcr.io/${{ github.repository_owner }}/my-core-bot-ts | |
| BOT_GO_IMAGE: ghcr.io/${{ github.repository_owner }}/my-core-bot-go | |
| RUNNER_AMD64: &RUNNER_AMD64 blacksmith-4vcpu-ubuntu-2404 # set this to ubuntu-24.04 for github hosted runners and X64 for self-hosted runners | |
| RUNNER_ARM64: &RUNNER_ARM64 blacksmith-4vcpu-ubuntu-2404-arm # set this to ubuntu-24.04-arm for github hosted runners and ARM64 for self-hosted runners | |
| concurrency: | |
| group: "${{ github.workflow }} @ ${{ github.ref_name }}" | |
| cancel-in-progress: true | |
| jobs: | |
| # PR validation for server image (no push) | |
| pr-build-test: | |
| if: github.event_name == 'pull_request' | |
| runs-on: *RUNNER_AMD64 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| # Use docker driver so bot build can see local server image | |
| - name: Set up Docker Buildx (driver=docker) | |
| id: builder | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker | |
| install: true | |
| use: true | |
| - name: Docker meta (server) | |
| id: meta-server | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.SERVER_IMAGE }} | |
| - name: Build server (PR, local only) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/server-Dockerfile | |
| builder: ${{ steps.builder.outputs.name }} | |
| platforms: linux/amd64 | |
| tags: local/server:pr-${{ github.event.pull_request.head.sha }} | |
| load: true | |
| push: false | |
| provenance: false | |
| - name: Build my-core-bot-c (PR, local only) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-c-Dockerfile | |
| builder: ${{ steps.builder.outputs.name }} | |
| platforms: linux/amd64 | |
| build-args: | | |
| SERVER_IMAGE=local/server | |
| TAG_NAME=pr-${{ github.event.pull_request.head.sha }} | |
| pull: false | |
| push: false | |
| provenance: false | |
| - name: Build my-core-bot-ts (PR, local only) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-ts-Dockerfile | |
| builder: ${{ steps.builder.outputs.name }} | |
| platforms: linux/amd64 | |
| build-args: | | |
| SERVER_IMAGE=local/server | |
| TAG_NAME=pr-${{ github.event.pull_request.head.sha }} | |
| pull: false | |
| push: false | |
| provenance: false | |
| - name: Build my-core-bot-go (PR, local only) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-go-Dockerfile | |
| builder: ${{ steps.builder.outputs.name }} | |
| platforms: linux/amd64 | |
| build-args: | | |
| SERVER_IMAGE=local/server | |
| TAG_NAME=pr-${{ github.event.pull_request.head.sha }} | |
| pull: false | |
| push: false | |
| provenance: false | |
| # Per-arch build: build server, tag temp per-arch for bot, then build bot β all in one job/matrix | |
| build-per-arch: | |
| if: github.event_name != 'pull_request' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| runner: *RUNNER_AMD64 | |
| platform: linux/amd64 | |
| - arch: arm64 | |
| runner: *RUNNER_ARM64 | |
| platform: linux/arm64 | |
| runs-on: | |
| - ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| echo "TEMP_TAG=${{ github.ref_name }}-ci-${{ matrix.arch }}-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_ENV | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Docker meta (server) | |
| id: meta-server | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.SERVER_IMAGE }} | |
| - name: Docker meta (my-core-bot-c) | |
| id: meta-bot-c | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_C_IMAGE }} | |
| - name: Docker meta (my-core-bot-ts) | |
| id: meta-bot-ts | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_TS_IMAGE }} | |
| - name: Docker meta (my-core-bot-go) | |
| id: meta-bot-go | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_GO_IMAGE }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Build server, push by digest; also create a temp per-arch tag for bot to consume immediately | |
| - name: Build and push by digest (server) | |
| id: build-server | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/server-Dockerfile | |
| platforms: ${{ matrix.platform }} | |
| labels: ${{ steps.meta-server.outputs.labels }} | |
| tags: ${{ env.SERVER_IMAGE }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| - name: Tag server image with temp per-arch tag | |
| run: | | |
| digest="${{ steps.build-server.outputs.digest }}" | |
| docker buildx imagetools create -t ${{ env.SERVER_IMAGE }}:${{ env.TEMP_TAG }} ${{ env.SERVER_IMAGE }}@${digest} | |
| - name: Export digest (server) | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests-server | |
| digest="${{ steps.build-server.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests-server/${digest#sha256:}" | |
| - name: Upload digest (server) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: server-digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/digests-server/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Build C bot on same runner arch, consuming the temp-tagged server image | |
| - name: Build and push by digest (my-core-bot-c) | |
| id: build-bot-c | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-c-Dockerfile | |
| build-args: | | |
| SERVER_IMAGE=${{ env.SERVER_IMAGE }} | |
| TAG_NAME=${{ env.TEMP_TAG }} | |
| platforms: ${{ matrix.platform }} | |
| labels: ${{ steps.meta-bot-c.outputs.labels }} | |
| tags: ${{ env.BOT_C_IMAGE }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| - name: Export digest (my-core-bot-c) | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests-bot-c | |
| digest="${{ steps.build-bot-c.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests-bot-c/${digest#sha256:}" | |
| - name: Upload digest (my-core-bot-c) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bot-c-digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/digests-bot-c/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Build TS bot on same runner arch, consuming the temp-tagged server image | |
| - name: Build and push by digest (my-core-bot-ts) | |
| id: build-bot-ts | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-ts-Dockerfile | |
| build-args: | | |
| SERVER_IMAGE=${{ env.SERVER_IMAGE }} | |
| TAG_NAME=${{ env.TEMP_TAG }} | |
| platforms: ${{ matrix.platform }} | |
| labels: ${{ steps.meta-bot-ts.outputs.labels }} | |
| tags: ${{ env.BOT_TS_IMAGE }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| - name: Export digest (my-core-bot-ts) | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests-bot-ts | |
| digest="${{ steps.build-bot-ts.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests-bot-ts/${digest#sha256:}" | |
| - name: Upload digest (my-core-bot-ts) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bot-ts-digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/digests-bot-ts/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Build Go bot on same runner arch, consuming the temp-tagged server image | |
| - name: Build and push by digest (my-core-bot-go) | |
| id: build-bot-go | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: ${{ github.workspace }} | |
| file: .github/workflows/my-core-bot-go-Dockerfile | |
| build-args: | | |
| SERVER_IMAGE=${{ env.SERVER_IMAGE }} | |
| TAG_NAME=${{ env.TEMP_TAG }} | |
| platforms: ${{ matrix.platform }} | |
| labels: ${{ steps.meta-bot-go.outputs.labels }} | |
| tags: ${{ env.BOT_GO_IMAGE }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| provenance: false | |
| - name: Export digest (my-core-bot-go) | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests-bot-go | |
| digest="${{ steps.build-bot-go.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests-bot-go/${digest#sha256:}" | |
| - name: Upload digest (my-core-bot-go) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bot-go-digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/digests-bot-go/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Merge server digests into multi-arch manifest | |
| push-server-merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: *RUNNER_AMD64 | |
| needs: build-per-arch | |
| steps: | |
| - name: Download digests (server) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: server-digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Docker meta (server) | |
| id: meta-server | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.SERVER_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=raw,value=${{ github.ref_name }}-${{ github.sha }} | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
| - name: Generate additional version tags (server) | |
| id: version-tags-server | |
| if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') | |
| run: | | |
| # Extract version from tag (remove 'v' prefix if present) | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} | |
| # Split version into parts | |
| IFS='.' read -r -a parts <<< "$VERSION" | |
| # Generate hierarchical tags based on number of parts | |
| ADDITIONAL_TAGS="" | |
| if [ ${#parts[@]} -ge 1 ]; then | |
| ADDITIONAL_TAGS="${{ env.SERVER_IMAGE }}:v${parts[0]}" | |
| fi | |
| if [ ${#parts[@]} -ge 2 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.SERVER_IMAGE }}:v${parts[0]}.${parts[1]}" | |
| fi | |
| if [ ${#parts[@]} -ge 3 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.SERVER_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}" | |
| fi | |
| if [ ${#parts[@]} -ge 4 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.SERVER_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}.${parts[3]}" | |
| fi | |
| echo "additional-tags=$ADDITIONAL_TAGS" >> $GITHUB_OUTPUT | |
| echo "Generated additional tags: $ADDITIONAL_TAGS" | |
| - name: Create manifest list and push (server) | |
| working-directory: ${{ runner.temp }}/digests | |
| run: | | |
| # Create manifest for base tags from metadata | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.SERVER_IMAGE }}@sha256:%s ' *) | |
| # Create manifest for additional version tags if they exist | |
| if [ -n "${{ steps.version-tags-server.outputs.additional-tags }}" ]; then | |
| IFS=',' read -r -a additional_tags <<< "${{ steps.version-tags-server.outputs.additional-tags }}" | |
| for tag in "${additional_tags[@]}"; do | |
| if [ -n "$tag" ]; then | |
| echo "Creating manifest for additional tag: $tag" | |
| docker buildx imagetools create -t "$tag" \ | |
| $(printf '${{ env.SERVER_IMAGE }}@sha256:%s ' *) | |
| fi | |
| done | |
| fi | |
| - name: Inspect image (server) | |
| run: | | |
| docker buildx imagetools inspect ${{ env.SERVER_IMAGE }}:${{ steps.meta-server.outputs.version }} | |
| # Merge C bot digests into multi-arch manifest | |
| push-bot-merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: *RUNNER_AMD64 | |
| needs: build-per-arch | |
| steps: | |
| - name: Download digests (my-core-bot-c) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests-bot-c | |
| pattern: bot-c-digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Docker meta (my-core-bot-c) | |
| id: meta-bot-c | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_C_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=raw,value=${{ github.ref_name }}-${{ github.sha }} | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
| - name: Generate additional version tags (my-core-bot-c) | |
| id: version-tags-bot-c | |
| if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') | |
| run: | | |
| # Extract version from tag (remove 'v' prefix if present) | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} | |
| # Split version into parts | |
| IFS='.' read -r -a parts <<< "$VERSION" | |
| # Generate hierarchical tags based on number of parts | |
| ADDITIONAL_TAGS="" | |
| if [ ${#parts[@]} -ge 1 ]; then | |
| ADDITIONAL_TAGS="${{ env.BOT_C_IMAGE }}:v${parts[0]}" | |
| fi | |
| if [ ${#parts[@]} -ge 2 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_C_IMAGE }}:v${parts[0]}.${parts[1]}" | |
| fi | |
| if [ ${#parts[@]} -ge 3 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_C_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}" | |
| fi | |
| if [ ${#parts[@]} -ge 4 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_C_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}.${parts[3]}" | |
| fi | |
| echo "additional-tags=$ADDITIONAL_TAGS" >> $GITHUB_OUTPUT | |
| echo "Generated additional tags: $ADDITIONAL_TAGS" | |
| - name: Create manifest list and push (my-core-bot-c) | |
| working-directory: ${{ runner.temp }}/digests-bot-c | |
| run: | | |
| # Create manifest for base tags from metadata | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.BOT_C_IMAGE }}@sha256:%s ' *) | |
| # Create manifest for additional version tags if they exist | |
| if [ -n "${{ steps.version-tags-bot-c.outputs.additional-tags }}" ]; then | |
| IFS=',' read -r -a additional_tags <<< "${{ steps.version-tags-bot-c.outputs.additional-tags }}" | |
| for tag in "${additional_tags[@]}"; do | |
| if [ -n "$tag" ]; then | |
| echo "Creating manifest for additional tag: $tag" | |
| docker buildx imagetools create -t "$tag" \ | |
| $(printf '${{ env.BOT_C_IMAGE }}@sha256:%s ' *) | |
| fi | |
| done | |
| fi | |
| - name: Inspect image (my-core-bot-c) | |
| run: | | |
| docker buildx imagetools inspect ${{ env.BOT_C_IMAGE }}:${{ steps.meta-bot-c.outputs.version }} | |
| # Merge bot digests into multi-arch manifest (TS) | |
| push-bot-ts-merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: *RUNNER_AMD64 | |
| needs: build-per-arch | |
| steps: | |
| - name: Download digests (my-core-bot-ts) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests-bot-ts | |
| pattern: bot-ts-digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Docker meta (my-core-bot-ts) | |
| id: meta-bot-ts | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_TS_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=raw,value=${{ github.ref_name }}-${{ github.sha }} | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
| - name: Generate additional version tags (my-core-bot-ts) | |
| id: version-tags-bot-ts | |
| if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') | |
| run: | | |
| # Extract version from tag (remove 'v' prefix if present) | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} | |
| # Split version into parts | |
| IFS='.' read -r -a parts <<< "$VERSION" | |
| # Generate hierarchical tags based on number of parts | |
| ADDITIONAL_TAGS="" | |
| if [ ${#parts[@]} -ge 1 ]; then | |
| ADDITIONAL_TAGS="${{ env.BOT_TS_IMAGE }}:v${parts[0]}" | |
| fi | |
| if [ ${#parts[@]} -ge 2 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_TS_IMAGE }}:v${parts[0]}.${parts[1]}" | |
| fi | |
| if [ ${#parts[@]} -ge 3 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_TS_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}" | |
| fi | |
| if [ ${#parts[@]} -ge 4 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_TS_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}.${parts[3]}" | |
| fi | |
| echo "additional-tags=$ADDITIONAL_TAGS" >> $GITHUB_OUTPUT | |
| echo "Generated additional tags: $ADDITIONAL_TAGS" | |
| - name: Create manifest list and push (my-core-bot-ts) | |
| working-directory: ${{ runner.temp }}/digests-bot-ts | |
| run: | | |
| # Create manifest for base tags from metadata | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.BOT_TS_IMAGE }}@sha256:%s ' *) | |
| # Create manifest for additional version tags if they exist | |
| if [ -n "${{ steps.version-tags-bot-ts.outputs.additional-tags }}" ]; then | |
| IFS=',' read -r -a additional_tags <<< "${{ steps.version-tags-bot-ts.outputs.additional-tags }}" | |
| for tag in "${additional_tags[@]}"; do | |
| if [ -n "$tag" ]; then | |
| echo "Creating manifest for additional tag: $tag" | |
| docker buildx imagetools create -t "$tag" \ | |
| $(printf '${{ env.BOT_TS_IMAGE }}@sha256:%s ' *) | |
| fi | |
| done | |
| fi | |
| - name: Inspect image (my-core-bot-ts) | |
| run: | | |
| docker buildx imagetools inspect ${{ env.BOT_TS_IMAGE }}:${{ steps.meta-bot-ts.outputs.version }} | |
| # Merge bot digests into multi-arch manifest (Go) | |
| push-bot-go-merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: *RUNNER_AMD64 | |
| needs: build-per-arch | |
| steps: | |
| - name: Download digests (my-core-bot-go) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests-bot-go | |
| pattern: bot-go-digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Docker meta (my-core-bot-go) | |
| id: meta-bot-go | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.BOT_GO_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=raw,value=${{ github.ref_name }}-${{ github.sha }} | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
| - name: Generate additional version tags (my-core-bot-go) | |
| id: version-tags-bot-go | |
| if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') | |
| run: | | |
| # Extract version from tag (remove 'v' prefix if present) | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} | |
| # Split version into parts | |
| IFS='.' read -r -a parts <<< "$VERSION" | |
| # Generate hierarchical tags based on number of parts | |
| ADDITIONAL_TAGS="" | |
| if [ ${#parts[@]} -ge 1 ]; then | |
| ADDITIONAL_TAGS="${{ env.BOT_GO_IMAGE }}:v${parts[0]}" | |
| fi | |
| if [ ${#parts[@]} -ge 2 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_GO_IMAGE }}:v${parts[0]}.${parts[1]}" | |
| fi | |
| if [ ${#parts[@]} -ge 3 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_GO_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}" | |
| fi | |
| if [ ${#parts[@]} -ge 4 ]; then | |
| ADDITIONAL_TAGS="$ADDITIONAL_TAGS,${{ env.BOT_GO_IMAGE }}:v${parts[0]}.${parts[1]}.${parts[2]}.${parts[3]}" | |
| fi | |
| echo "additional-tags=$ADDITIONAL_TAGS" >> $GITHUB_OUTPUT | |
| echo "Generated additional tags: $ADDITIONAL_TAGS" | |
| - name: Create manifest list and push (my-core-bot-go) | |
| working-directory: ${{ runner.temp }}/digests-bot-go | |
| run: | | |
| # Create manifest for base tags from metadata | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.BOT_GO_IMAGE }}@sha256:%s ' *) | |
| # Create manifest for additional version tags if they exist | |
| if [ -n "${{ steps.version-tags-bot-go.outputs.additional-tags }}" ]; then | |
| IFS=',' read -r -a additional_tags <<< "${{ steps.version-tags-bot-go.outputs.additional-tags }}" | |
| for tag in "${additional_tags[@]}"; do | |
| if [ -n "$tag" ]; then | |
| echo "Creating manifest for additional tag: $tag" | |
| docker buildx imagetools create -t "$tag" \ | |
| $(printf '${{ env.BOT_GO_IMAGE }}@sha256:%s ' *) | |
| fi | |
| done | |
| fi | |
| - name: Inspect image (my-core-bot-go) | |
| run: | | |
| docker buildx imagetools inspect ${{ env.BOT_GO_IMAGE }}:${{ steps.meta-bot-go.outputs.version }} |