Skip to content

improvements

improvements #38

name: Docker
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SMOKE_TEST_IMAGE: schema-gov-it-mcp:ci
jobs:
build-smoke-test:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image for validation
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: ${{ env.SMOKE_TEST_IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start container
run: |
docker run -d \
--name schema-gov-it-mcp-smoke \
-p 3000:3000 \
-e MCP_TRANSPORT=http \
${{ env.SMOKE_TEST_IMAGE }}
- name: Smoke test health endpoint
run: |
for i in $(seq 1 20); do
if curl -fsS http://127.0.0.1:3000/health; then
exit 0
fi
sleep 2
done
echo "Container did not become healthy in time" >&2
docker logs schema-gov-it-mcp-smoke
exit 1
- name: Stop container
if: always()
run: docker rm -f schema-gov-it-mcp-smoke || true
publish:
if: github.event_name != 'pull_request'
needs: build-smoke-test
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max