@ChristopherHX thanks for the suggestion. I've tried what was recommended using single quotes around 'EOF', but that never worked.

The workaround was using base64 encode/decode and storing the entire config as a single secret instead of injecting the values runtime when setting up CLI utils config.

mkdir -p "$HOME/.config/openstack" echo "${{ secrets.CLOUDS_YAML_B64 }}" | base64 --decode > "$HOME/.config/openstack/clouds.yaml"

There is some scope for improvement in terms of end-user experience, rather than having to escape the special chars ('$') or think about how many languages need to be interpreted in my steps.

🌐
SSW.Rules
ssw.com.au › rules › handle-special-characters-on-github
Do you know how to handle special characters in GitHub Secrets and Variables? | SSW.Rules
When storing Secrets and Variables in GitHub, it's common that these are stored with special characters (for example: "$", "&", "(", ")", "<", ">").
Discussions

How can I handle special characters with GitHub secret when moving them around?
To handle special characters in the .env file, it may help to Base64 encode the contents stored in the secret. The following works for me: - run: echo ${{ secrets.ENV_FILE }} | base64 --decode > .env shell: bash More on reddit.com
🌐 r/github
5
2
July 31, 2024
Unable to store special characters in github secrets - Stack Overflow
I am trying to store my password as GitHub secret. However, I am getting 401 unauthorized error. It appears to me that the GitHub secrets doesn't work if the value contains a special character. The... More on stackoverflow.com
🌐 stackoverflow.com
Secret with special/escape characters fails when used
The Fastlane script expects the token to be available via environment variable FASTLANE_SESSION so I am exporting the value of the secret as the environment variable per the GitHub actions documentation. It should be noted that the token string has special and escaped characters and Apple expects ... More on github.com
🌐 github.com
2
6
How can we identify the special characters that cannot be directly given as GitHub Actions Secrets - Stack Overflow
I was working with GitHub Action pipeline codes and I used Action Secrets for storing secret values. When I added some secrets, I found that it was not working as expected. Later I found out that some special characters cannot be directly given as GitHub Secrets. More on stackoverflow.com
🌐 stackoverflow.com
October 26, 2022
🌐
Medium
medium.com › @susovanpanja › how-to-handle-special-characters-in-your-github-secret-ec7492d1bbca
How to Handle Special Characters in your GitHub Secret | by Susovan Panja | Medium
January 8, 2024 - I need to store this secret as a GitHub secret and use it for another command. Now we can add an escape character before special characters while creating a secret so that when using GitHub Workflows they render correctly i.e.
🌐
Reddit
reddit.com › r/github › how can i handle special characters with github secret when moving them around?
r/github on Reddit: How can I handle special characters with GitHub secret when moving them around?
July 31, 2024 -

I am having an issue with GitHub Actions where I am having difficultly with my project trying to setup the environment variables loaded from a secret.

Within my project I read and load my environment variables from a `.dev.env` file as follows,

from dotenv import load_dotenv
load_dotenv(join(dirname(__file__), ".dev.env"))

The necessary components of the workflow for creating the `.dev.env` is,

      - name: Create .dev.env file
        working-directory: app/backend
        run: printf "${{ secrets.DEV_DOT_ENV }}" > .dev.env

Despite my environment variables loading when running locally, it consistently fails on GitHub Actions. My secret is set to the name `DEV_DOT_ENV` and is a single multiline output that is the content of my local `.dev.env`, a small snippet is (slightly changed secrets),

DEBUG="TRUE"

DJANGO_SECRET_KEY="django-insecure-_l6iqyh=er-f3ap!cwmod@p(!48l!yr123456789_"

FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCo37T214PIWAok\n+egKZKSDgq..."

I believe that I am having difficulty getting a 1 to 1 copy of the assigned string into the file.

At first I attempted to use echo ${{ secrets.DEV_DOT_ENV }} > .dev.env but ran into issues with the new line characters inside the `FIREBASE_PRIVATE_KEY` as it treated the spaces as seperation within the echo and also treated the \n inside the file as a backslash n and not an actual new line character.

From here I learnt to surround it in quotes in order to prevent this, but it seems the `!` it causing issues inside the DJANGO_SECRET_KEY, e.g.

printf DJANGO_SECRET_KEY="django-insecure-_l6iqyh=er-f3ap!cwmod@p(!48l!y" > t

will give me an errors, despite being quote surrounded. At this point I do not know how get a 1:1 mapping of the content I put inside as I keep running inside errors with new line characters, ! and quotes that inside the YAML file.

The latest error on the workflow execution was

/home/runner/work/_temp/1ff40a34-f08f-487a-b814-2d8635379afd.sh: line 3: syntax error near unexpected token `('

My secret into GitHub was assigned a name, `DEV_DOT_ENV` where I plopped the multiline string containing the special characters that I want the `load_dotenv` to find and load. How can this be accomplished?

🌐
GitHub
docs.github.com › actions › security-guides › using-secrets-in-github-actions
Using secrets in GitHub Actions - GitHub Docs
If you must pass secrets within ... unintentionally affect your shell. To escape these special characters, use quoting with your environment variables....
🌐
Stack Overflow
stackoverflow.com › questions › 74204204 › how-can-we-identify-the-special-characters-that-cannot-be-directly-given-as-gith
How can we identify the special characters that cannot be directly given as GitHub Actions Secrets - Stack Overflow
October 26, 2022 - I was working with GitHub Action pipeline codes and I used Action Secrets for storing secret values. When I added some secrets, I found that it was not working as expected. Later I found out that some special characters cannot be directly given as GitHub Secrets.
Find elsewhere
🌐
GitHub
github.com › github › docs › issues › 21626
Add section with special characters that need to be escaped when used in GitHub secret value · Issue #21626 · github/docs
October 26, 2022 - It could be interesting to add a section to the Encrypted Secrets page (like the "Naming your secrets" section) informing what rules have to be followed, such as which special characters need to be escaped when used in a GitHub secret value (e.g: use \$ instead of $).
Author   GuillaumeFalourd
🌐
DEV Community
dev.to › foresthoffman › combining-github-secrets-and-actions-4081
Combining GitHub Secrets and Actions - DEV Community
August 19, 2021 - GitHub calls it, “Actions secrets”, ... is quite clear regarding the rules regarding Secrets, such as: Names may only contain alphanumeric characters and underscores (e.g....
🌐
GitHub
github.com › firebase › firebase-tools › issues › 4695
Function secrets with special characters are returned with the escape backslash · Issue #4695 · firebase/firebase-tools
June 16, 2022 - export const test = functions .runWith({ secrets: ['TEST_SECRET'] }) .region('europe-west1') .https.onRequest((req, res) => { console.log(process.env.TEST_SECRET); // \\\\123\\\\123 console.log(functions.config().TEST_SECRET); // \\123\\123 res.send('OK'); }); We can notice that the special characters in the secret that is saved to process.env get escaped, and the escaped characters are included as part of the returned string.
Author   tooga
🌐
GitHub
github.com › InseeFrLab › images-datascience › issues › 182
Allow special characters in secret values · Issue #182 · InseeFrLab/images-datascience
February 7, 2024 - ( ) | # & ? * characters are currently forbidden in secret values. Would be nice to allow them since secrets are used as string as precised in #125
🌐
GitHub
github.com › hashicorp › vault › issues › 12277
vault unable to read secrets with special characters · Issue #12277 · hashicorp/vault
August 6, 2021 - Describe the bug in the vault ui we have a secret with special character ( a single backslah ) . we are unable to read the secrets using the command : vault read -field=data -format=json secret/dat...
Author   navneet1075
🌐
GitHub
docs.github.com › en › actions › reference › security › secrets
Secrets reference - GitHub Docs
To help ensure that GitHub redacts your secrets in logs correctly, avoid using structured data as the values of secrets. ... Can only contain alphanumeric characters ([a-z], [A-Z], [0-9]) or underscores (_).
🌐
GitHub
docs.github.com › enterprise-server@3.10 › actions › security-guides › using-secrets-in-github-actions
Using secrets in GitHub Actions - GitHub Enterprise Server 3.10 Docs
If you must pass secrets within ... unintentionally affect your shell. To escape these special characters, use quoting with your environment variables....
🌐
GitHub
docs.github.com › en › enterprise-cloud@latest › get-started › using-git › dealing-with-special-characters-in-branch-and-tag-names
Dealing with special characters in branch and tag names - GitHub Enterprise Cloud Docs
March 15, 2022 - If a branch name includes the $ character, then the shell must be stopped from expanding it as a variable reference. Similarly, if a branch name contains a semi-colon (;), most shells interpret it as a command separator, so it needs to be quoted or escaped. Most branch and tag names with special characters can be handled by including the name in single quotes, for example 'hello-$USER'.