Skip to content

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

Open
Quantum-Electronic-Devices/One-Inch-Photodetector
#21

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

Activity

  1. added
    bug
    on Aug 23, 2023
  2. mike-carey commented on Aug 30, 2023

    @mike-carey

    I can confirm that this also used to work for us and recently broke. We are going to have to change a lot of workflows if we need to implement the workaround which is to use a different variable: github.event.head_commit.ref. It appears it is not just on release that this is causing issues.

    Related threads:

  3. slayoo commented on Sep 6, 2023

    @slayoo

    Same here, our PyPI uploads stopped to work in August, we are using:

        - if: startsWith(github.ref, 'refs/tags')
          uses: pypa/gh-action-pypi-publish@unstable/v1
    

    (https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/tests%2Bpypi.yml)

  4. mariuszste commented on Sep 14, 2023

    @mariuszste

    the GITHUB_REF env variable is also empty

  5. kakuzei commented on Sep 27, 2023

    @kakuzei

    This issue has a significant impact on the delivery of the application I am working on.
    The behavior is quite weird: sometimes the GITHUB_REF environment variable is well populated, sometimes it is empty.
    Could someone from GitHub provide a clear status about this issue?
    When this issue will be fixed?
    Is there a workaround we can setup in the meantime?

    Thanks

  6. flaxel commented on Sep 27, 2023

    @flaxel

    A possible workaround could be the usage of the release event. 🙌 Then you can get the version with the following path: github.event.release.tag_name.

  7. sangdth commented on Oct 8, 2023

    @sangdth

    Currently I'm trying to get the PR number from GITHUB_REF, my workflows is triggered by the deployment_status, and after 3 hours I found out it is empty.

  8. itsHenry35 commented on Nov 3, 2023

    @itsHenry35

    same issue, so i use github.event.release.tag_name as a workaround
    image
    image

  9. 21 remaining items

  10. added a commit that references this issue on Aug 8, 2025
  11. added a commit that references this issue on Mar 27, 2026
  12. bcmedeiros commented on Jun 22, 2026

    @bcmedeiros

    I'm pretty sure there's an incident going on in the last couple of days that is causing this behaviour to happen 100% of the release triggers. We are also experiencing a huge delay between a release being created and it being listed in the /releases page.
    My support ticket has been ignored, and I just found this 3-year-old bug. 🤡

  13. added a commit that references this issue on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions