Search code examples
githubgithub-actions

Do I need quotes to substitute Github workflow substitution in string?


I defined the input to a Github workflow action like so. To create the string values, I enclose the substitution in double-quotes, to follow how it would be in Bash:

 uses: dmnemec/[email protected]
    env:
      API_TOKEN_GITHUB: ${{ secrets.GH_API_TOKEN }}
    with:
      source_file: "${{ steps.create-copy-file.outputs.filename }}.yaml"
      destination_repo: "${{ github.repository_owner }}/repo"
      destination_folder: "releases/${{ steps.create-copy-file.outputs.target_folder }}"
      user_email: "[email protected]"
      user_name: "User Name"

However, examples in Github shows that I can substitute for the value without needing to enclose it in quotes. I tried defining the values above without quotes and they seem to work i.e. the file is copied correctly to the target repo and folder.

 uses: dmnemec/[email protected]
    env:
      API_TOKEN_GITHUB: ${{ secrets.GH_API_TOKEN }}
    with:
      source_file: ${{ steps.create-copy-file.outputs.filename }}.yaml
      destination_repo: ${{ github.repository_owner }}/repo
      destination_folder: releases/${{ steps.create-copy-file.outputs.target_folder }}
      user_email: [email protected]
      user_name: "User Name"

I tried looking for examples in Github to know whether this practice is allowed or suggested but couldn't find any. The one example I have found is from this Azure developer page (example no.6): https://learn.microsoft.com/en-us/azure/developer/github/github-variable-substitution.

Another example, wraps the string in double quotes.

My question is, is it necessary to enclose string substitution in Github workflow in single/double quotes? Is this an officially supported feature or an unintended feature?


Solution

  • No, generally you do not need quotes. The workflow file is YAML and this is all about quotes in YAML:

    YAML: Do I need quotes for strings in YAML?