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.

Configuration variables are empty when passed as secrets to reusable workflow

See original GitHub issue

Describe 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:

  1. Setup a Repository or Organization based configuration variable in settings:
MY_VAR=some-value
  1. 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'
                  
  1. Create a main workflow with a job that reusing workflow from previous step
  2. 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:open
  • Created 8 months ago
  • Reactions:7
  • Comments:11

github_iconTop GitHub Comments

2reactions
glency-betterteemcommented, Mar 30, 2023

As of the moment, this is still ongoing issue. using vars outputs blank.

2reactions
dtcMLOpscommented, Feb 17, 2023

same problem for me

Read more comments on GitHub >

github_iconTop 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 >

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