Closed
Description
Troubleshooting
Before submitting a bug report please read the Troubleshooting doc.
Behaviour
Using {{branch}}
as outlined in https://github.com/docker/metadata-action#global-expressions does not work when pushing commits to a branch with a PR open.
Steps to reproduce this issue
- Open a PR for new branch
- Push commits
- Observe output of workflow
Expected behaviour
Docker tags should be outputted as follows assuming a branch foo
and sha 12345
my/repo:12345-amd64
my/repo:foo-amd64
my/repo:foo-12345-amd64
Actual behaviour
{{branch}}
is empty so the tags are as follows:
my/repo:12345-amd64
my/repo:-amd64
my/repo:-12345-amd64
Configuration
name: docker-metadata-test
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]
jobs:
name: docker-metadata-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: my/repo
tags: |
type=raw,value={{sha}}-amd64
type=raw,value={{branch}}-amd64
type=raw,value={{branch}}-{{sha}}-amd64
Logs
metadata step of logs with some parts redacted
2022-04-20T00:00:44.3789494Z ##[group]Run docker/metadata-action@v3
2022-04-20T00:00:44.3789795Z with:
2022-04-20T00:00:44.3790108Z images: my/repo
2022-04-20T00:00:44.3790585Z tags: type=raw,value={{sha}}-amd64
type=raw,value={{branch}}-amd64
type=raw,value={{branch}}-{{sha}}-amd64
2022-04-20T00:00:44.3791171Z github-token: ***
2022-04-20T00:00:44.3791392Z ##[endgroup]
2022-04-20T00:00:44.8175981Z ##[group]Context info
2022-04-20T00:00:44.8232603Z eventName: pull_request
2022-04-20T00:00:44.8232917Z sha: 137b7b03cf19010d9f14a6315a7d8d7741b99b4a
2022-04-20T00:00:44.8233160Z ref: refs/pull/80/merge
2022-04-20T00:00:44.8233385Z workflow: docker-metadata-test
2022-04-20T00:00:44.8233598Z action: meta
2022-04-20T00:00:44.8233787Z actor: evandam
2022-04-20T00:00:44.8233989Z runNumber: 124
2022-04-20T00:00:44.8234191Z runId: 2192825535
2022-04-20T00:00:44.8234662Z ##[endgroup]
2022-04-20T00:00:44.8235061Z ##[group]Processing tags input
2022-04-20T00:00:44.8235683Z type=raw,value={{sha}}-amd64,enable=true,priority=200
2022-04-20T00:00:44.8236093Z type=raw,value={{branch}}-amd64,enable=true,priority=200
2022-04-20T00:00:44.8236831Z type=raw,value={{branch}}-{{sha}}-amd64,enable=true,priority=200
2022-04-20T00:00:44.8237290Z ##[endgroup]
2022-04-20T00:00:44.8237665Z ##[group]Processing flavor input
2022-04-20T00:00:44.8237895Z latest=auto
2022-04-20T00:00:44.8238091Z prefix=
2022-04-20T00:00:44.8238279Z prefixLatest=false
2022-04-20T00:00:44.8238484Z suffix=
2022-04-20T00:00:44.8238678Z suffixLatest=false
2022-04-20T00:00:44.8239104Z ##[endgroup]
2022-04-20T00:00:44.8326167Z ##[group]Docker image version
2022-04-20T00:00:44.8326749Z 137b7b0-amd64
2022-04-20T00:00:44.8327230Z ##[endgroup]
2022-04-20T00:00:44.8348648Z ##[group]Docker tags
2022-04-20T00:00:44.8349280Z my/repo:137b7b0-amd64
2022-04-20T00:00:44.8349838Z my/repo:-amd64
2022-04-20T00:00:44.8350355Z my/repo:-137b7b0-amd64
2022-04-20T00:00:44.8351069Z ##[endgroup]
2022-04-20T00:00:44.8353443Z ##[group]Docker labels
2022-04-20T00:00:44.8353828Z org.opencontainers.image.title=my_repo
2022-04-20T00:00:44.8354284Z org.opencontainers.image.description=description
2022-04-20T00:00:44.8354824Z org.opencontainers.image.url=https://github.com/my/repo
2022-04-20T00:00:44.8355332Z org.opencontainers.image.source=https://github.com/my/repo
2022-04-20T00:00:44.8355840Z org.opencontainers.image.version=137b7b0-amd64
2022-04-20T00:00:44.8356377Z org.opencontainers.image.created=2022-04-20T00:00:44.822Z
2022-04-20T00:00:44.8356850Z org.opencontainers.image.revision=137b7b03cf19010d9f14a6315a7d8d7741b99b4a
2022-04-20T00:00:44.8357230Z org.opencontainers.image.licenses=
2022-04-20T00:00:44.8357770Z ##[endgroup]
2022-04-20T00:00:44.8358909Z ##[group]JSON output
2022-04-20T00:00:44.8359141Z {
2022-04-20T00:00:44.8359395Z "tags": [
2022-04-20T00:00:44.8359898Z "my/repo:137b7b0-amd64",
2022-04-20T00:00:44.8360652Z "my/repo:-amd64",
2022-04-20T00:00:44.8361195Z "my/repo:-137b7b0-amd64"
2022-04-20T00:00:44.8361544Z ],
2022-04-20T00:00:44.8361757Z "labels": {
2022-04-20T00:00:44.8363964Z "org.opencontainers.image.title": "my_repo",
2022-04-20T00:00:44.8364504Z "org.opencontainers.image.description": "description",
2022-04-20T00:00:44.8364981Z "org.opencontainers.image.url": "https://github.com/my/repo",
2022-04-20T00:00:44.8365506Z "org.opencontainers.image.source": "https://github.com/my/repo",
2022-04-20T00:00:44.8366099Z "org.opencontainers.image.version": "137b7b0-amd64",
2022-04-20T00:00:44.8366684Z "org.opencontainers.image.created": "2022-04-20T00:00:44.822Z",
2022-04-20T00:00:44.8367285Z "org.opencontainers.image.revision": "137b7b03cf19010d9f14a6315a7d8d7741b99b4a",
2022-04-20T00:00:44.8367724Z "org.opencontainers.image.licenses": ""
2022-04-20T00:00:44.8368040Z }
2022-04-20T00:00:44.8368250Z }
2022-04-20T00:00:44.8368809Z ##[endgroup]
2022-04-20T00:00:44.8370169Z ##[group]Bake definition file
2022-04-20T00:00:44.8370447Z {
2022-04-20T00:00:44.8371202Z "target": {
2022-04-20T00:00:44.8371777Z "docker-metadata-action": {
2022-04-20T00:00:44.8372031Z "tags": [
2022-04-20T00:00:44.8372504Z "my/repo:137b7b0-amd64",
2022-04-20T00:00:44.8373187Z "my/repo:-amd64",
2022-04-20T00:00:44.8373693Z "my/repo:-137b7b0-amd64"
2022-04-20T00:00:44.8374050Z ],
2022-04-20T00:00:44.8374327Z "labels": {
2022-04-20T00:00:44.8374689Z "org.opencontainers.image.title": "my_repo",
2022-04-20T00:00:44.8375124Z "org.opencontainers.image.description": "description",
2022-04-20T00:00:44.8375657Z "org.opencontainers.image.url": "https://github.com/my/repo",
2022-04-20T00:00:44.8376194Z "org.opencontainers.image.source": "https://github.com/my/repo",
2022-04-20T00:00:44.8376702Z "org.opencontainers.image.version": "137b7b0-amd64",
2022-04-20T00:00:44.8377253Z "org.opencontainers.image.created": "2022-04-20T00:00:44.822Z",
2022-04-20T00:00:44.8377729Z "org.opencontainers.image.revision": "137b7b03cf19010d9f14a6315a7d8d7741b99b4a",
2022-04-20T00:00:44.8378187Z "org.opencontainers.image.licenses": ""
2022-04-20T00:00:44.8378466Z },
2022-04-20T00:00:44.8378768Z "args": {
2022-04-20T00:00:44.8379288Z "DOCKER_META_IMAGES": "my/repo",
2022-04-20T00:00:44.8379716Z "DOCKER_META_VERSION": "137b7b0-amd64"
2022-04-20T00:00:44.8380053Z }
2022-04-20T00:00:44.8380309Z }
2022-04-20T00:00:44.8380513Z }
2022-04-20T00:00:44.8380792Z }
2022-04-20T00:00:44.8381452Z ##[endgroup]
Download the log file of your build and attach it to this issue.