docker / metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
https://github.com/marketplace/actions/docker-metadata-action
Apache License 2.0
901 stars 117 forks source link

semver based on branch names #98

Open devinrsmith opened 3 years ago

devinrsmith commented 3 years ago

I'd like to kick off semver tags based on git branch names, as opposed to git tag names.

For example:

push refs/heads/release/v1.2.3 1.2.3, 1.2

It doesn't seem like this is possible with type=semver since that only works on git tags. type=pattern likewise doesn't apply. type=ref,event=branch, while applying to branches, doesn't allow custom patterns.

Any help would be much appreciated!

devinrsmith commented 3 years ago

I've got a hacky workaround that looks something like this:

      - name: Get Semver
        id: semver
        if: ${{ startsWith(github.ref, 'refs/heads/release/v') }}
        run: |
          semver=$(echo ${{ github.ref }} | tail -c +21)
          echo "::set-output name=semver::$semver"

...

            type=raw,enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.semver.outputs.semver }}
crazy-max commented 3 years ago

@devinrsmith That could be done through type=match def but it's only supported for tags atm. Maybe also with #56.