Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose pull request head ref as {{branch}} variable #485

Open
fabn opened this issue Nov 26, 2024 · 0 comments
Open

Expose pull request head ref as {{branch}} variable #485

fabn opened this issue Nov 26, 2024 · 0 comments

Comments

@fabn
Copy link

fabn commented Nov 26, 2024

Description

When using {{branch}} variable in a pull_request event the output is '' (as documented).

It would be super useful to have it populated with github.event.pull_request.head.ref to compose tags like the following:

        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ github.repository }}
          tags: |
            type=sha,format=short,prefix={{branch}}-

At the moment I'm doing something like:

        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ github.repository }}
          tags: |
            type=sha,format=short,prefix=${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '{{branch}}' }}-

But it seems a hack to me, is there any drawback in doing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant