docker / docker/metadata-action

Flavor is ignored in output, despite being parsed properly

Open
#270 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
TypeScript
Stars
1.1k
Forks
160
Avg merge
4d 17h
Merged PRs (30d)
12

Description

Behaviour

Even though I've specified a flavor which contains a prefix, and it is parsed properly, it doesn't result in a prefix on the docker tags which are produced. This prefix is being used in a matrix to allow two different packages to be built into images. Apologies if I'm missing something obvious (it feels like I must be?).

I'm using the following flavor:

          flavor: |
            latest=auto
            prefix=${{ matrix.package }}-,onlatest=true
            suffix=

I've tried this with a few different combinations, including both with tags specified and without, as well as messing with the onlatest, but none of this appears to change the behavior.

Thanks tons!

Steps to reproduce this issue
  1. Configure the workflow with a flavors defined, which specifies a prefix
  2. Run the action
  3. Observe incorrect output
Expected behaviour

Docker tags should be generated with a prefix; in the case of the above, it should be ghcr.io/fardog/primebot:twitter-pr-12.

Actual behaviour

Docker tags ignore the prefix; e.g. ghcr.io/fardog/primebot:pr-12

Configuration

The repository URL contains a few different attempts within that PR, none of the configs I attempted were successful however.

name: Docker Image

on:
  push:
    branches: 
      - master
    tags:
  pull_request:

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build-and-push-image:
    strategy:
      matrix:
        package: ["twitter", "mastodon"]
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v3

      - uses: docker/login-action@v2
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - id: meta
        uses: docker/metadata-action@v4
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          flavor: |
            latest=auto
            prefix=${{ matrix.package }}-,onlatest=true
            suffix=
          tags: |
            type=schedule
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=ref,event=branch
            type=ref,event=pr
            type=sha

      - name: Build and push Docker image
        uses: docker/build-push-action@v4
        with:
          context: .
          file: Dockerfile-${{ matrix.package }}
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
Logs

logs_32.zip

Attached; also here is a screenshot of relevant output.

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported workflow configuration, including the matrix.package value, flavor block, tags, and Dockerfile-${{ matrix.package }} build input; compare the generated tags with the attached logs and linked Actions runs. Done means the configured prefix appears in the generated Docker tags, including the expected ghcr.io/fardog/primebot:twitter-pr-12 output.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, github-actions, typescript
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.