How To Reveal GitHub-Actions Secrets
By default, gh-actions secrets are read-only, and their log output is hidden. A simple trick can reveal their values.
You can create or add to an existing workflow a job step that echo
s a secret and pipes it into sed
which will add a space between each character, thereby tricking & bypassing GitHub's secrets exposure analysis, revealing secrets in plaintext.
name: Reveal Secrets
on: [workflow_dispatch]
jobs:
reveal-secrets:
runs-on: ubuntu-latest
steps:
- name: Reveal secrets
run: |
echo "SECRET_NAME=${{ secrets.SECRET_NAME }}" | sed 's/./& /g'
After merging the PR into your master
/main
branch, you can go to your repo's Actions, select this new Workflow, and manually run the Workflow. In the Workflow's output you will see the revealed secrets. Copy/paste the results into a text editor and search/replace the space character with nothing.
If your secrets contain spaces, modify the sed
command to inject one or more special characters instead of spaces: sed 's/./&!!!/g'
echo "secret contains spaces" | sed 's/./&!!!/g'
s!!!e!!!c!!!r!!!e!!!t!!! !!!c!!!o!!!n!!!t!!!a!!!i!!!n!!!s!!! !!!s!!!p!!!a!!!c!!!e!!!s!!!