chore(ci): use `docker/metadata-action` (#756)
* chore(ci): use `docker/metadata-action` - Replace custom `setup-image-vars` action by `docker/metadata-action` - Automatically add latest tag on semver tag Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): add image tag on PR Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): cleanup trailing spaces Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> * chore(ci): remove `setup-image-vars` action Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be> --------- Signed-off-by: Ronny Moreas <ronny.moreas@kuleuven.be>
This commit is contained in:
		
							parent
							
								
									a817997ed8
								
							
						
					
					
						commit
						d34cfaafa1
					
				|  | @ -1,35 +0,0 @@ | |||
| name: "Setup Image Variables" | ||||
| 
 | ||||
| inputs: | ||||
|   dockerfile: | ||||
|     required: true | ||||
| 
 | ||||
| outputs: | ||||
|   tag: | ||||
|     description: "The tag if run against a tag, otherwise 'canary'" | ||||
|     value: ${{ steps.vars.outputs.tag }} | ||||
|   suffix: | ||||
|     description: "The suffix for the image package name (if any)" | ||||
|     value: ${{ steps.vars.outputs.suffix }} | ||||
| 
 | ||||
| runs: | ||||
|   using: "composite" | ||||
|   steps: | ||||
|     - name: Get reference and suffix | ||||
|       id: vars | ||||
|       shell: bash | ||||
|       env: | ||||
|         DOCKERFILE: ${{ inputs.dockerfile }} | ||||
|       run: | | ||||
|         TAG=${GITHUB_REF##*/} | ||||
|         if [[ $GITHUB_REF == refs/heads/main ]]; then | ||||
|             TAG=canary | ||||
|         elif [[ $GITHUB_REF == refs/pull/*/merge ]]; then | ||||
|             TAG=pullrequest  # this 'tag' is just used for caching | ||||
|         fi | ||||
|         echo ::set-output name=tag::${TAG:-canary} | ||||
|         SUFFIX=${DOCKERFILE##Dockerfile} | ||||
|         if [[ "${SUFFIX}" == "."* ]]; then | ||||
|             SUFFIX=${SUFFIX//./-}  # convert dots into dashes | ||||
|         fi | ||||
|         echo ::set-output name=suffix::${SUFFIX} | ||||
|  | @ -30,10 +30,13 @@ jobs: | |||
|       packages: write | ||||
|     strategy: | ||||
|       matrix: | ||||
|         dockerfile: | ||||
|           - Dockerfile | ||||
|           - Dockerfile.debian-stable-slim | ||||
|           - Dockerfile.ubuntu | ||||
|         image: | ||||
|           - dockerfile: Dockerfile | ||||
|             suffix: "" | ||||
|           - dockerfile: Dockerfile.debian-stable-slim | ||||
|             suffix: "-debian-stable-slim" | ||||
|           - dockerfile: Dockerfile.ubuntu | ||||
|             suffix: "-ubuntu" | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|  | @ -48,11 +51,16 @@ jobs: | |||
|         with: | ||||
|           version: latest | ||||
| 
 | ||||
|       - name: Set up Image Variables | ||||
|         id: vars | ||||
|         uses: ./.github/actions/setup-image-vars | ||||
|       - name: Docker meta | ||||
|         id: meta | ||||
|         uses: docker/metadata-action@v4 | ||||
|         with: | ||||
|           dockerfile: ${{ matrix.dockerfile }} | ||||
|           images: ghcr.io/${{ github.repository }}${{ matrix.image.suffix }} | ||||
|           flavor: latest=true | ||||
|           tags: | | ||||
|             type=raw,value=canary,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||||
|             type=ref,event=pr | ||||
|             type=semver,pattern={{raw}} | ||||
| 
 | ||||
|       - name: Login to GitHub Container Registry | ||||
|         uses: docker/login-action@v1 | ||||
|  | @ -65,10 +73,10 @@ jobs: | |||
|         uses: docker/build-push-action@v3 | ||||
|         with: | ||||
|           context: . | ||||
|           file: ${{ matrix.dockerfile }} | ||||
|           file: ${{ matrix.image.dockerfile }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | ||||
|           tags: | | ||||
|             ghcr.io/${{ github.repository }}${{ steps.vars.outputs.suffix }}:${{ steps.vars.outputs.tag }} | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|           cache-from: type=gha | ||||
|           cache-to: type=gha,mode=max | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue