question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing in secrets to reusable workflow does not work without secrets in env

See original GitHub issue

We are trying out Github Actions and have run into a curious issue which we think is a bug. We have configured secrets at the organization level, and are trying to pass those secrets in to a reusable workflow as shown below:

name: example

on:
  pull_request:
    branches:
      - gh-actions

jobs:
  test:
    uses: northvolt/example/.github/workflows/review-common.yml@gh-actions
    secrets:
      password: ${{ secrets.PASSWORD }}

This does not work. password shows up blank in the reusable workflow instead of having the value of the secret.

If we instead add env: ${{ secrets }} to the top-level of the manifest, all of a sudden the secret gets passed in to the workflow. This seems quite counterintuitive since passing in secrets should not be related to the env, and this behavior does not appear to be documented anywhere. In fact, this example of secrets in reusable workflows does not need an env key set at the top-level.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:18

github_iconTop GitHub Comments

60reactions
woutersfcommented, Aug 29, 2022

For future me: secrets:inherit fixed it for me: In the calling job:

jobs:  
  deploy-tst-custom:
    uses: ./.github/workflows/thejob.yml
    secrets: inherit

*edited typo

21reactions
param-findercommented, Jun 20, 2022

Spent hours on this dreaded issue. CircleCI is so much better when it comes to re-usability. Github Actions lack good documentation and features!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Secrets are not available on Reusable ...
Problem : Passing an environment containing secrets to a reusable workflow is not enough to have the environment secrets avaiable.
Read more >
Consuming Environment Secrets in Reusable Workflows
The documentation explains that reusable workflows can access secrets via the secrets keyword, and does mention environments, but it's not very ...
Read more >
Referencing environment secrets in reusable workflows
I have been able to pass and reference organization and repository secrets in reusable workflows without any issues. The problem(bug) is ...
Read more >
GitHub Actions fails to fetch secrets within reusable workflows
1. Explicitly add secrets to the reusable workflow – similar to inputs – and pass each of them individually from the parent workflow....
Read more >
Simplify using secrets with reusable workflows
GitHub Actions simplifies using secrets with reusable workflows with the secrets: inherit keyword. Previously when passing secrets to a reusable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found