github.ref is empty for workflows triggered by release
Nobody has claimed this yet.
- 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 [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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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