Writing Github secret to a file

I’m trying to save secret to a file, it’s an important requirement for the build process.

- name: Save Credentials
  run: 'echo "$SECRET_KEY" | base64 --decode > secret_file.json'
  shell: bash
  env:
    SSH_KEY: ${{secrets.SECRET_KEY}}

But it’s only giving me empty file. How do I do it properly ?

Your env variable was named  SSH_KEY not SECRET_KEY :

- name: Save Credentials
  run: 'echo "$SSH_KEY" | base64 --decode > secret_file.json'
  shell: bash
  env:
    SSH_KEY: ${{secrets.SECRET_KEY}}
1 Like

Oh okay, thanks.