0

What is the use of the '$' symbol (after branch=, sha_short= and commit_date=) in the below code for extracting the commit id details in a Github action workflow run on ubuntu

  - name: Extract the commit ID
    id: vars
    shell: bash
    run: |
      echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
      echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
      echo "commit_date = $(git show -s --format=%cd --date=short)" >> $GITHUB_OUTPUT
torek
  • 448,244
  • 59
  • 642
  • 775
Sathish_ks
  • 41
  • 3
  • 1
    When you use `${...}` you are referring to an environment variable, so the `branch` here basically concatenate an env variable with a string before saving it in the GITHUB_OUTPUT context variable. When you use `$(...)` in `sha_short` and `commit_date` you basically want to attribute a command line output result to a variable (in that case, before saving it in the GITHUB_OUTPUT context variable as well). – GuiFalourd Nov 11 '22 at 08:52

0 Answers0