Skip to content

Commit 2a33332

Browse files
test: non-matrix platform action build
Signed-off-by: Scott Schreckengaust <[email protected]>
1 parent 399be89 commit 2a33332

File tree

1 file changed

+107
-9
lines changed
  • .github/actions/build-and-push-container-image

1 file changed

+107
-9
lines changed

.github/actions/build-and-push-container-image/action.yml

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,113 @@ outputs:
4343
runs:
4444
using: "composite"
4545
steps:
46-
- id: get-version
47-
name: Workflow ${{ github.workflow }} Job ${{ github.job }} Action ${{ github.action }} Number ${{ github.run_number }} Attempt ${{ github.run_attempt }}
46+
- name: Docker meta
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
#ADD LATER
51+
# public.ecr.aws/mcp/awslabs/${{ inputs.image }}
52+
# ghcr.io/awslabs/mcp/awslabs/${{ inputs.image }}
53+
images: |
54+
docker.io/awslabs/${{ inputs.image }}
55+
56+
# Disable all but the raw and sha
57+
tags: |
58+
type=schedule,enable=false
59+
type=semver,pattern={{raw}},enable=false
60+
type=pep440,pattern={{raw}},enable=false
61+
type=match,pattern=(.*),group=1,enable=false
62+
type=edge,enable=false
63+
type=ref,event=branch,enable=false
64+
type=ref,event=tag,enable=false
65+
type=ref,event=pr,enable=false
66+
type=sha,format=long,enable=true
67+
type=raw,value=latest,enable=true # {{is_default_branch}} doesn't work
68+
type=raw,value=${{ inputs.version || github.sha }},enable=${{ (inputs.version && true) || 'false' }}
69+
labels: |
70+
maintainer=AWSLabs MCP
71+
org.opencontainers.image.description=AWS Labs ${{ inputs.image }} MCP Server
72+
org.opencontainers.image.source=https://github.com/awslabs/mcp/tree/main/src/${{ inputs.image }}
73+
org.opencontainers.image.title=awslabs.${{ inputs.image }}
74+
org.opencontainers.image.url=https://github.com/awslabs/mcp/tree/main/src/${{ inputs.image }}
75+
org.opencontainers.image.version=${{ inputs.version || github.sha }}
76+
org.opencontainers.image.vendor=Amazon Web Service, Inc.
77+
78+
- name: Login to Docker Hub
79+
id: login-docker-hub
80+
uses: docker/login-action@v3
81+
with:
82+
username: ${{ secrets.DOCKERHUB_USERNAME }}
83+
password: ${{ secrets.DOCKERHUB_TOKEN }}
84+
85+
- name: Login to GitHub Container Registry
86+
id: login-github-container-registry
87+
uses: docker/login-action@v3
88+
with:
89+
registry: ghcr.io
90+
username: awslabs-mcp
91+
password: ${{ secrets.BOT_GITHUB_TOKEN }}
92+
93+
# - name: Login to Public ECR
94+
# uses: docker/login-action@v3
95+
# with:
96+
# registry: <aws-account-number>.dkr.ecr.<region>.amazonaws.com
97+
# registry: public.ecr.aws
98+
# username: ${{ vars.AWS_ACCESS_KEY_ID }}
99+
# password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
100+
# env:
101+
# AWS_REGION: <region>
102+
103+
- name: Set up QEMU
104+
id: setup-qemu
105+
uses: docker/setup-qemu-action@v3
106+
107+
- name: Set up Docker Buildx
108+
id: setup-buildx
109+
uses: docker/setup-buildx-action@v3
110+
with:
111+
buildkitd-flags: --debug
112+
113+
- name: Build and push by digest
114+
id: build
115+
uses: docker/build-push-action@v6
116+
with:
117+
platforms: 'linux/amd64,linux/arm64' # less effient than matrix, but actions cannot deal with it...
118+
labels: ${{ steps.meta.outputs.labels }}
119+
#tags: docker.io/${{ github.repository_owner }}/${{ inputs.image }},ghcr.io/${{ github.repository }}/${{ inputs.image }}
120+
tags: docker.io/${{ github.repository_owner }}/${{ inputs.image }}
121+
context: ./src/${{ inputs.image }}
122+
file: ./src/${{ inputs.image }}/Dockerfile
123+
push: true
124+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
125+
126+
- name: Export digest
127+
run: |
128+
mkdir -p ${{ runner.temp }}/digests
129+
digest="${{ steps.build.outputs.digest }}"
130+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
131+
shell: bash
132+
- name: Upload digest
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: digests
136+
path: ${{ runner.temp }}/digests/*
137+
if-no-files-found: error
138+
retention-days: 1
139+
140+
- name: Create manifest list and push
141+
working-directory: ${{ runner.temp }}/digests
142+
run: |
143+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
144+
$(printf 'awslabs/${{ inputs.image }}@sha256:%s ' *)
145+
shell: bash
146+
- name: Inspect image
147+
run: |
148+
docker buildx imagetools inspect awslabs/${{ inputs.image }}:${{ steps.meta.outputs.version }}
149+
shell: bash
150+
- name: Get version
151+
id: get-version
48152
working-directory: ${{ env.GITHUB_WORKSPACE }}
49153
run: |
50-
echo "Is there an ${{ inputs.image }}???"
51-
pwd
52-
ls -al .
53-
echo "Reporting the input version as the output version..."
54-
echo version="${{ inputs.version }}" >>"$GITHUB_OUTPUT"
55-
env:
56-
IMAGE: ${{ inputs.image }}
154+
echo version="${{ steps.meta.outputs.version }}" >>"$GITHUB_OUTPUT"
57155
shell: bash

0 commit comments

Comments
 (0)