Skip to content

Instantly share code, notes, and snippets.

@boris-42
Created March 31, 2025 01:36
Show Gist options
  • Save boris-42/cb18dc58acaa8c54a7642144fde30e11 to your computer and use it in GitHub Desktop.
Save boris-42/cb18dc58acaa8c54a7642144fde30e11 to your computer and use it in GitHub Desktop.
name: Set Variable to Tag or SHA
on:
push:
tags:
- '*'
branches:
- '**'
jobs:
set-var:
runs-on: ubuntu-latest
steps:
- name: Get tag or commit SHA
id: vars
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
else
echo "VERSION=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
fi
- name: Show VERSION
run: echo "Version is ${{ steps.vars.outputs.VERSION }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment