GitHub Action using docker image with same tag/ref?

Hello!

I’m trying to create an action which is running on a docker image with the same tag/ref.
For example, if action is spawned using user/action@v2 it’ll use ghcr.io/user/action:v2 and if it were used with user/action@my-branch it’ll use ghcr.io/user/action:my-branch instead.

The thing is that I would like to avoid changing the used docker image action.yml manually (especially since the aim is to publish them with automation).

Is there any way to achieve this easily ?


What I’ve currently tried is to create a composite GitHub action instead and spawn the docker action manually :

# action.yml
runs:
  using: composite
  steps:
  - run: |
      docker run ghcr.io/user/action:$TAG
    env:
        TAG: ${{ "???" }}

But I cannot find a way to retrieve the used tag (thought the ${{ github.action }} would be any help, but it does not contains the ref/tag).

Plus it seems to be a workaround for something that may be easier to achieve.

Any help appreciated, have a nice day!