简体   繁体   English

关键字机密在 github 操作工作流中不起作用

[英]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: ./.github/workflows/build_job 文件夹包含 action.yml 文件:

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'错误:工作流无效..github/workflows/build_workflow.yml(行:16,列:9):意外值“秘密”

在此处输入图像描述

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 .另请参阅我的这个关于复合操作和可重用工作流之间区别的另一个答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM