@@ -5,44 +5,54 @@ name: Create and publish docker image
55# - A tag starting with "v" is created
66# - A pull request is created or updated
77on :
8+ workflow_dispatch :
89 push :
910 branches :
10- - main
11+ - ' main'
1112 tags :
12- - v*
13- pull_request :
13+ - ' v*'
1414
1515env :
16+ REGISTRY : ghcr.io
1617 IMAGE_NAME : mcp-server-github-codeowners
18+
1719jobs :
1820 # This pushes the image to GitHub Packages.
19- push :
21+ build-and- push :
2022 runs-on : ubuntu-latest
2123 permissions :
22- packages : write
2324 contents : read
25+ packages : write
26+ attestations : write
27+ id-token : write
2428 steps :
25- - uses : actions/checkout@v4
26-
27- - name : Build image
28- run : docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
29-
30- - name : Log in to registry
31- run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
32-
33- - name : Push image
34- run : |
35- IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
36-
37- # This changes all uppercase characters to lowercase.
38- IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
39- # This strips the git ref prefix from the version.
40- VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
41- # This strips the "v" prefix from the tag name.
42- [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
43- # This uses the Docker `latest` tag convention.
44- [ "$VERSION" == "main" ] && VERSION=latest
45- echo IMAGE_ID=$IMAGE_ID
46- echo VERSION=$VERSION
47- docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
48- docker push $IMAGE_ID:$VERSION
29+ - name : Checkout repository
30+ uses : actions/checkout@v5
31+
32+ - name : Set up QEMU
33+ uses : docker/setup-qemu-action@v3
34+
35+ - name : Set up Docker Buildx
36+ uses : docker/setup-buildx-action@v3
37+
38+ - name : Log in to the Container registry
39+ uses : docker/login-action@v3
40+ with :
41+ registry : ${{ env.REGISTRY }}
42+ username : ${{ github.actor }}
43+ password : ${{ secrets.GITHUB_TOKEN }}
44+
45+ - name : Metadata action
46+ id : meta
47+ uses : docker/metadata-action@v5
48+ with :
49+ images : ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME}}
50+
51+ - name : Build and push
52+ uses : docker/build-push-action@v6
53+ with :
54+ context : .
55+ platforms : linux/amd64,linux/arm64
56+ push : true
57+ tags : ${{ steps.meta.outputs.tags }}
58+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments