关键词 secrets 在 Github Actions 工作流中无法使用。

3
调用可重复使用的工作流程:
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 文件夹包含 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"

错误:工作流程无效。.github/workflows/build_workflow.yml(第16行,第9列):未预期的值“secrets”。

enter image description here

1个回答

3

你正在将可重复使用的工作流程包含为一个步骤,但可重复使用的工作流程是整个作业而不仅仅是一个步骤。

因此,你需要的是:

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

然后,由于您不能再从外部进行结帐,因此您需要将结帐添加到可重复使用的工作流中。

还可以查看我在组合操作和可重复使用工作流之间区别方面的另一个答案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接