0

So i found a few code samples using github action with # (not for comment) any idea what the # purpose is?

run: |
 echo "::set-output name=docker_tag:: $repo/$image:${tag#refs/heads}"

And because I wasn't confuse enought, I endup finding that:

  run: |
    ./node_modules/vsce/out/vsce package
    echo "##[set-output name=version;]$(npm run package-version --silent)"

I understand the purpose of set-output, it's just the # that I don't understand.

both run on ubuntu-latest.

Edit : I don't have the basis on shell

sab
  • 4,352
  • 7
  • 36
  • 60
  • Does this answer your question? [Syntax with pound and percent sign after shell parameter name](https://stackoverflow.com/questions/36036561/syntax-with-pound-and-percent-sign-after-shell-parameter-name) – Benjamin W. Apr 16 '20 at 12:42
  • 1
    `${tag#refs/heads}` is a parameter expansion of the variable `$tag` that removes the string `refs/heads` from the beginning; e.g., if `tag=refs/heads/master`, then `${tag#refs/heads}` is just `master`. – Benjamin W. Apr 16 '20 at 12:43
  • The second echo prints literally `##[set-output name=version;]` and then the output of the command `npm run package-version --silent`. – Benjamin W. Apr 16 '20 at 12:44
  • 1
    The second one is strange, as in GitHub Actions, special strings are used as [workflow commands](https://help.github.com/en/actions/reference/workflow-commands-for-github-actions), but they use `::` and not `##`. – Benjamin W. Apr 16 '20 at 12:46
  • 3
    @BenjaminW. IIRC, `##` syntax was used in early beta and changed later to `::` – Samira Apr 16 '20 at 14:53
  • @Samira That would explain it :) – Benjamin W. Apr 16 '20 at 15:09

0 Answers0