actions / actions/runner

github.ref is empty for workflows triggered by release

Open
#2,788 16 comments 67 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

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 if [[ "" == refs/tags/release/* ]] ; then
2023-08-23T09:37:27.3088599Z     current_version=$( echo  | cut -c19- )
2023-08-23T09:37:27.3088944Z     echo "version_number=${current_version}" >> $GITHUB_OUTPUT
2023-08-23T09:37:27.3089250Z else
2023-08-23T09:37:27.3089574Z     echo "::error ::Could not determine the version number using ref "
2023-08-23T09:37:27.3089900Z     exit 1
2023-08-23T09:37:27.3090122Z fi

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the release-triggered workflow on Linux with runner versions 2.307.1 and 2.308.0, using the reported step and logging github.ref. Compare the release event context with the documented behavior and inspect the runner's event-context handling. Done means the expected release tag ref is available or the discrepancy is clearly resolved and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, shell
Domain
ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.