Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keyword secrets is not working in github actions workflow

Workflow that call reusable one:

name: Build only workflow

on:
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/workflows/build_job
        with:
          TARGET: lol
        secrets: inherit

./.github/workflows/build_job folder contain action.yml file:

name: Build job

on:
  workflow_call:
    inputs:
      TARGET:
        required: true
        type: string

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: webfactory/ssh-agent@v0.5.4
        with:
            ssh-private-key: ${{secrets.SSH_KEY}}
      - run: echo "hello"

Error: The workflow is not valid. .github/workflows/build_workflow.yml (Line: 16, Col: 9): Unexpected value ‘secrets’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

You’re including the reusable workflow as a step, but a reusable workflow is an entire job not just a step.

Therefore, what you need is:

jobs:
  my-job:
    uses: ./.github/workflows/my-reusable-workflow.yaml

And then, since you can’t do the checkout from outside anymore, you’re going to have to add the checkout to your reusable workflow.

Also see this other answer of mine on the distinction between composite actions and reusable workflows.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading