Configuration variables are empty when passed as secrets to reusable workflow
See original GitHub issueDescribe the bug Configuration variables (introduced recently by Github) are empty when passed as secrets to a reusable workflow.
To Reproduce Steps to reproduce the behavior:
- Setup a Repository or Organization based configuration variable in settings:
MY_VAR=some-value
- Create a test reusable workflow with some secret as a parameter, like:
on:
workflow_call:
secrets:
my-secret:
required: false
jobs:
my-job:
name: My Job
runs-on: ubuntu-latest
steps:
- name: Test Vars
run: |
echo '${{ secrets.my-secret }}' | sed 's/./& /g'
- Create a main workflow with a job that reusing workflow from previous step
- Pass the configuration variable as a secret, like:
on:
workflow_dispatch:
jobs:
build:
name: Step1
uses: <my-org>/github-actions/.github/workflows/test-workflow.yaml@main
secrets:
my-secret: ${{ vars.MY_VAR }}
Expected behavior output of MY_VAR (with spaces between letters to unmask the value)
Runner Version and Platform
2.301.1
Ubuntu
What’s not working?
If you modify the test, add inputs to reusable workflow and pass the var to the input at the same time with passing that to secrets, THAT WORKS! That is the reason, why it was qualified as a bug and not a feature.
Here is a workaround:
# Reusable workflow
on:
workflow_call:
secrets:
my-secret:
required: false
inputs:
my-input:
required: false
type: string
default: ''
jobs:
my-job:
name: My Job
runs-on: ubuntu-latest
steps:
- name: Test Vars
run: |
echo '${{ secrets.my-secret }}' | sed 's/./& /g'
# Main workflow
on:
workflow_dispatch:
jobs:
build:
name: Step1
uses: <my-org>/github-actions/.github/workflows/test-workflow.yaml@main
secrets:
my-secret: ${{ vars.MY_VAR }}
with:
my-input: ${{ vars.MY_VAR }}
Issue Analytics
- State:
- Created 8 months ago
- Reactions:7
- Comments:11
Top Results From Across the Web
Passing env variable inputs to a reusable workflow
I'm trying to call a reusable workflow from another one, passing it some input variables. In the caller workflow I have some environment...
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 >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 ...
Read more >Github action secret env. You must authenticate using an ac
Github action secret env. You must authenticate using an access token with the admin:org scope to use this endpoint. Find centralized, trusted content...
Read more >GitHub Actions fails to fetch secrets within reusable workflows
Secrets need to be passed from within the parent workflow. There are two ways to solve this: 1. Explicitly add secrets to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As of the moment, this is still ongoing issue. using vars outputs blank.
same problem for me