Skip to content

github.ref is empty for workflows triggered by release #2788

@paolonevis

Description

@paolonevis

With the following step:

    - name: Determining the version number
      if: ${{ github.event_name == 'release' }}
      id: version_number
      run: |
        if [[ "${{ github.ref }}" == refs/tags/release/* ]] ; then
            current_version=$( echo ${{ github.ref }} | cut -c19- )
            echo "version_number=${current_version}" >> $GITHUB_OUTPUT
        else
            echo "::error ::Could not determine the version number using ref ${{ github.ref }}"
            exit 1
        fi

I'd expect that the github.ref contains the release tag created (as described in https://docs.github.com/en/actions/learn-github-actions/contexts#github-context), but I get an empty github.ref (here the extract from the raw log):

2023-08-23T09:37:27.3087882Z ##[group]Run if [[ "" == refs/tags/release/* ]] ; then
2023-08-23T09:37:27.3088257Z �[36;1mif [[ "" == refs/tags/release/* ]] ; then�[0m
2023-08-23T09:37:27.3088599Z �[36;1m    current_version=$( echo  | cut -c19- )�[0m
2023-08-23T09:37:27.3088944Z �[36;1m    echo "version_number=${current_version}" >> $GITHUB_OUTPUT�[0m
2023-08-23T09:37:27.3089250Z �[36;1melse�[0m
2023-08-23T09:37:27.3089574Z �[36;1m    echo "::error ::Could not determine the version number using ref "�[0m
2023-08-23T09:37:27.3089900Z �[36;1m    exit 1�[0m
2023-08-23T09:37:27.3090122Z �[36;1mfi�[0m

This did work 3 weeks ago with runner version: '2.307.1'.

OS of the machine running the runner: linux

Runner version: 2.308.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions