Jorge Leitao
Jorge Leitao

Reputation: 20103

Get GitHub Action version inside the action

Consider a GitHub Action that:

  1. Downloads a binary
  2. Untars and runs the binary

The binary version depends on the version of the action. When the action is used like

uses: action_x@v3

I am trying to get the v3 inside the action, so that I can map it to the corresponding binary version.

Is there a way to do this without having to hard-code the binary version on the YAML file (and remember to bump it on release)?

Upvotes: 1

Views: 106

Answers (1)

munro
munro

Reputation: 125

Looking at GitHub Contexts, it seems that github.action_ref should contain what you are looking for:

For a step executing an action, this is the ref of the action being executed. For example, v2.

jobs:
  show_checkout_version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: echo '${{ github.action_ref }}'

Upvotes: 3

Related Questions