I am trying to pass secrets to reusable workflow as shown here: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#passing-inputs-and-secrets-to-a-reusable-workflow
But the pipeline fails, stating that:
The workflow is not valid. .github/workflows/test.workflow-test.yml (Line: 17, Col: 9): Unexpected value 'secrets'
My .github/actions/test/action.yml looks like that:
name: Reusable workflow example
on:
workflow_call:
inputs:
username:
required: true
type: string
secrets:
token:
required: true
jobs:
example_job:
name: show
runs-on: ubuntu-latest
steps:
- name: show data
runs: echo ${{ secrets.token }}
And I'm calling it accordingly:
name: Call a reusable workflow
on:
push:
branches:
- "feature/workflow-test"
jobs:
my-test-job:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- uses: ./.github/actions/test
with:
username: John
secrets:
token: secret Token
What I am missing here? It is almost identical to the code samples within GitHub's documentation.
There are two issues that I can see with your example.
The path to reusable workflow needs to be .github/workflows
. Currently subdirs are not supported.
Also, the way you call reusable workflow is not according to docs.
Here's an example that should work:
name: Call a reusable workflow
on:
workflow_dispatch:
jobs:
reusable-job:
uses: <owner>/<repo>/.github/workflows/<reusable workflow>@master
with:
username: john
secrets:
token: test
And following reusable workflow:
name: Reusable workflow
on:
workflow_call:
inputs:
username:
required: true
type: string
secrets:
token:
required: true
jobs:
show:
runs-on: ubuntu-latest
steps:
- name: Show data
run: |
echo ${{ inputs.username }}
echo ${{ secrets.token}}