The first one doesn’t work because you’re trying to call the reusable workflow in a step, which isn’t possible (that’s for custom actions). A reusable workflow must be called at the job level.
Point three under Using inputs and secrets in a reusable workflow has an example. I notice it also says there:
Workflows that call reusable workflows in the same organization or enterprise can use the
inheritkeyword to implicitly pass the secrets.
I hope that doesn’t mean you can’t use that for workflows owned by the same personal account.
Support secret inheritence `secrets: inherit` for actions
Enhancement: Streamlining secret inheritance to environment in reusable workflows
How to use reusable GitHub workflows and keep secrets in a single place? - Stack Overflow
Actions: Expand `secrets: inherit` documentation
Videos
Check if the new (May 2022) keyword secrets: inherit can help:
GitHub Actions: Simplify using secrets with reusable workflows
GitHub Actions simplifies using secrets with reusable workflows with the
secrets: inheritkeyword.Previously when passing secrets to a reusable workflow, you had to pass each secret as a separate argument.
Now you can simply pass the
secrets: inheritto the reusable workflow and the secrets will be inherited from the calling workflow.
Learn more about reusable workflows in GitHub Actions and jobs.<job_id>.steps[*].uses.
In the reusable workflow, reference the input or secret that you defined in the on key in the previous step.
If the secrets are inherited using
secrets: inherit, you can reference them even if they are not defined in the on key.jobs: reusable_workflow_job: runs-on: ubuntu-latest environment: production steps: - uses: ./.github/workflows/my-action with: username: ${{ inputs.username }} token: ${{ secrets.envPAT }}In the example above,
envPATis an environment secret that is been added to the production environment. That environment is therefore referenced within the job.Note: Environment secrets are encrypted strings that are stored in an environment that you have defined for a repository. Environment secrets are only available to workflow jobs that reference the appropriate environment. For more information, see "Using environments for deployment."
Again, see jobs.<job_id>.steps[*].uses for additional examples.
As noted by wkhatch in the comments:
I do not believe this syntax is correct for using a reusable workflow, but is correct for using reusable actions. You cannot call a reusable workflow as a step, but you can with an action.
March 2025: As noted by Mickael V.'s comment, if you rely only on secrets: inherit without further organization, you would indeed have to set the secrets individually in all calling repositories... which does not scale well.
Sept. 2025: tamas.kenez comments that the caller job that uses a reusable workflow supports only with: and secrets:. Putting environment: there triggers Unexpected value 'environment'.
That means you would need to put environment: inside the called workflow's own job(s).
As an example of a reusable (called) workflow in a central repository (using here slackapi/slack-github-action:
# secrets-repo/.github/workflows/slack-notify.yml
name: Notify Slack
on:
workflow_call:
inputs:
message:
required: true
type: string
jobs:
notify_slack:
runs-on: ubuntu-latest
environment: production
steps:
- name: Send Slack notification
uses: slackapi/slack-github-action@v2
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: ${{ inputs.message }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Called by:
# any-repo/.github/workflows/notify.yml
name: Call central Slack notify
on:
push:
branches: [ main ]
jobs:
notify:
uses: my-org/secrets-repo/.github/workflows/slack-notify.yml@main
with:
message: "Build successful"
secrets: inherit
Kaspar H comments: "secrets resolve to the caller's repo, not the called repo"
That seems to be the default with reusable workflows (and with secrets: inherit): the called workflow receives the caller's secrets. To centralize secrets once and avoid per-repo duplication, keep them as environment secrets in the called repo, and make the called workflow's jobs declare environment:.
This exact scenario is addressed in the GitHub roadmap issue GitHub Actions secrets improvements for Reusable workflows:
With this current improvement, teams managing reusable workflows can refer to the secrets from the called (source) repos. These secrets are available only in the reusable workflow run context within in the caller (target) repos.
Unfortunately, as of March 2024, the issue is scheduled for "Future"; there are columns up to Q4 2024.
I'm running Github Actions within my organization's repos. I created a reusable workflow that I apply to multiple repos.
Here is a snippet from the reusable workflow:
name: reusable-workflow
on:
workflow_call:
inputs:
post_build_custom_command:
description: "Custom command to run after build"
required: false
type: string
default: ''
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build
run: npm run build
- name: Post Build Custom Command
run: |
${{ inputs.post_build_custom_command }}
if: ${{ inputs.post_build_custom_command }}
I want to specifically focus on the Post Build Custom Command task. I had to create this "custom command" input to run a bash script which is custom to the caller repo.
In my caller repo, I call the reusable workflow as so:
name: caller-workflow
on:
pull_request:
branches: [main]
jobs:
reusable-workflow:
name: reusable-workflow
uses: org/workflows/.github/workflows/reusable-workflow.yml@main
with:
post_build_custom_command: |
echo "${{ secrets.PRIVATE_KEY }}" > /tmp/key.pem
secrets: inheritI get the following error:
The workflow is not valid. .github/workflows/workflow.yml (Line: 23, Col: 34): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.PRIVATE_KEY
Can someone help me to find a fix or a workaround for this?