diff --git a/.github/actions/setup-image-vars/action.yaml b/.github/actions/setup-image-vars/action.yaml deleted file mode 100644 index c9cdd975..00000000 --- a/.github/actions/setup-image-vars/action.yaml +++ /dev/null @@ -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} diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index ed68bf2a..ddb92c5d 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -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