Thursday, November 11, 2021

Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException Unrecognized named-value: 'secrets'

 ErrorGitHub.DistributedTask.ObjectTemplating.TemplateValidationExceptionThe template is not valid. /home/runner/work/test/test/./.github/actions/test/action.yml (Line22, Col14)Unrecognized named-value'secrets'. Located at position 1 within expressionsecrets.PASS


Fix: actions does not have access to secrets, only the workflow is allowed to access secrets.


workflow to pass the secret as:

with:
  secret_input: ${{ secrets.SUPER_SECRET }}

And then, in action.yml,

inputs:
  secret_input: 
     description: "..."
     required: true
...

runs:
.....
  - name: .....
    env:
      MY_SECRET: ${{ inputs.secret_input }}