Skip to content

test: defaults for core #4

test: defaults for core

test: defaults for core #4

---
# Builds a multi-architecture image based on input path
name: Build and Push Container Image
on:
# Temporary to get started...
push:
branches: ["feature/push-container-images"]
workflow_dispatch:
inputs:
tag:
default: 'awslabs/core-mcp-server'
type: string
required: true
working-directory:
default: './src/core-mcp-server'
type: string
required: true
workflow_call:
inputs:
tag:
type: string
required: true
working-directory:
default: ${{ github.workspace }}
type: string
required: false
docker-file:
default: './Dockerfile'
type: string
required: false
# jobs:
# pass-secrets-to-workflow:
# uses: ./.github/workflows/build-and-push-container-image.yml
# secrets: inherit
secrets:
DOCKERHUB_USERNAME:
description: 'The docker login'
required: true
DOCKERHUB_TOKEN:
description: 'The docker token for the login'
required: true
AWS_ROLE_ARN_TO_ASSUME:
description: 'The role to assume for the ECR repository'
required: true
BOT_GITHUB_TOKEN:
description: 'The token for the bot user'
required: true
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working-directory || './src/core-mcp-server' }}
environment: release
# if: (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call')
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.tag || 'awslabs/test-mcp-server' }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ inputs.tag || 'awslabs/test-mcp-server' }}
context: ${{ inputs.working-directory || './src/core-mcp-server' }}
file: ${{ inputs.docker-file || 'Dockerfile' }}
push: false # During testing use `false`
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call')
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.tag || 'awslabs/test-mcp-server' }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ inputs.tag || 'awslabs/test-mcp-server' }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ inputs.tag || 'awslabs/test-mcp-server' }}:${{ steps.meta.outputs.version }}