1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5-
6- # GitHub recommends pinning actions to a commit SHA.
7- # To get a newer version, you will need to update the SHA.
8- # You can also reference a tag or branch, but the action may change without warning.
9-
10- name : Build and push Docker image to GHCR
1+ name : Build and test Docker images
112
123on :
4+ push :
5+ branches :
6+ - ' release-**'
137 workflow_dispatch :
14- release :
15- branches : [ main ]
16- types : [ published ]
178
189env :
19- REGISTRY : ghcr.io
20- IMAGE_NAME : ${{ github.repository }}
2110 PLATFORMS : linux/amd64,linux/arm64,linux/arm/v7
2211
2312jobs :
24- build_and_push_image :
13+ build_and_test_images :
2514 runs-on : ubuntu-22.04
2615 permissions :
2716 contents : read
@@ -37,24 +26,39 @@ jobs:
3726 - name : Set up Docker Buildx
3827 uses : docker/setup-buildx-action@v2
3928
29+ - name : Log in to Docker Hub
30+ uses : docker/login-action@v2
31+ with :
32+ username : ${{ secrets.DOCKER_USERNAME }}
33+ password : ${{ secrets.DOCKER_PASSWORD }}
34+
4035 - name : Log in to the Container registry
4136 uses : docker/login-action@v2
4237 with :
43- registry : ${{ env.REGISTRY }}
38+ registry : ghcr.io
4439 username : ${{ github.actor }}
4540 password : ${{ secrets.GITHUB_TOKEN }}
4641
42+ - id : docker-image-to-lowercase
43+ name : Convert Docker image to lower case
44+ run : echo "DOCKER_IMAGE=$(echo ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
45+
4746 - name : Extract metadata (tags, labels) for Docker
4847 id : meta
4948 uses : docker/metadata-action@v4
5049 with :
51- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+ images : |
51+ ${{ env.DOCKER_IMAGE }}
52+ ghcr.io/${{ github.repository }}
53+ tags : |
54+ type=semver,pattern={{version}}
55+ type=semver,pattern={{major}}.{{minor}}
5256
53- - name : Build and push image to GHCR
57+ - name : Build and push Docker images
5458 uses : docker/build-push-action@v3
5559 with :
5660 context : .
57- push : true
61+ push : false
5862 platforms : ${{ env.PLATFORMS }}
5963 tags : ${{ steps.meta.outputs.tags }}
6064 labels : ${{ steps.meta.outputs.labels }}
0 commit comments