question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add both version tag and branch name tag

See original GitHub issue

I have the following configuration:

            type=raw,value={{branch}}
            type=sha
            type=semver,pattern={{version}}

But when I push just a tag to the main branch, the container is tagged only with latest, 1.0.0 and sha tags, but not with the branch name.

Is it possible to always have a branch name tag in addition to version tag? The goal is to be able to refer either to a specific version tag or the latest container build in each branch.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
max-arnoldcommented, Oct 19, 2021

Ok, it worked after I added a couple of tweaks.

  1. This snippet I found on the internet was immensely helpful in debugging the variables:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
  1. The solution that works both for tag pushes and branch pushes looks like this (although it needs more testing)
      - name: Base ref
        run: |
          if [ "${{ github.ref_type }}" = "tag" ]; then BASEREF="${{ github.event.base_ref }}"; BASEREF="${BASEREF#refs/heads/}"; elif [ "${{ github.ref_type }}" = "branch" ]; then BASEREF="${{ github.ref_name }}"; else BASEREF=""; fi
          echo "BASEREF=${BASEREF}" >> $GITHUB_ENV
0reactions
max-arnoldcommented, Oct 19, 2021

Thanks a lot! I’ll test the workaround in a couple of days.

And yes, a global expression would be nice: https://github.com/docker/metadata-action/issues/102#issuecomment-859083282

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git - Tagging - Git SCM
Git supports two types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn't change — it's...
Read more >
Is it possible to have version tags on multiple branches in git?
1 Answer 1 · Actually, tag names do work a lot like branch names in Git. The issue here is that branch names...
Read more >
git tag | Atlassian Git Tutorial
Git tag command is the primary driver of tag: creation, modification and deletion. Learn how you can use them to organize code and...
Read more >
Fixing GIT Branch and Tag Name Collisions - Geedew
You should never name a tag and a branch the same name! It makes sense in a case like this to use naming...
Read more >
Branch and tag with same name cause multiple problems
Pushing a branch with the same name as a tag causes multiple problems throughout the GitLab application. I will list them here, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found