Abh*_*hek 14 continuous-integration github-actions
我正在使用可重用工作流程,当将secrets调用者工作流程传递到可重用工作流程时,我收到以下语法错误:
The workflow is not valid. .github/workflows/caller_workflow.yml (Line: 28, Col: 28): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.SECRET_1 .github/workflows/caller_workflow.yml (Line: 29, Col: 22): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.SECRET_2
Run Code Online (Sandbox Code Playgroud)
不知道为什么插值不起作用。
这是我的呼叫者工作流程caller_workflow.yml(给出上述错误):
name: Build workflow
on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- edited
- reopened
branches:
- main
- dev
jobs:
# reference: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#example-caller-workflow
org-checks:
uses: repo/.github/workflows/main_workflow.yml@main
with:
SECRET_1: ${{ secrets.SECRET_1 }}
SECRET_2: ${{ secrets.SECRET_2 }}
Run Code Online (Sandbox Code Playgroud)
这是我的可重用工作流程:
name: Build workflow
on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- edited
- reopened
branches:
- main
- dev
jobs:
# reference: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#example-caller-workflow
org-checks:
uses: repo/.github/workflows/main_workflow.yml@main
with:
SECRET_1: ${{ secrets.SECRET_1 }}
SECRET_2: ${{ secrets.SECRET_2 }}
Run Code Online (Sandbox Code Playgroud)
其他流程中的秘密使用相同的语法都可以正常工作。
Abh*_*hek 21
我以错误的方式传递了秘密。在我的工作流程中,秘密是使用with输入参数传递的,因此出现错误。with 将输入传递给被调用(可重用)工作流程时可以正常工作,但不能用于机密。为了传递秘密,请使用secrets参数。
这里更新了caller_workflow.yaml:
name: Build workflow
on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- edited
- reopened
branches:
- main
- dev
jobs:
# reference: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#example-caller-workflow
org-checks:
uses: repo/.github/workflows/main_workflow.yml@main
secrets:
SECRET_1: ${{ secrets.SECRET_1 }}
SECRET_2: ${{ secrets.SECRET_2 }}
Run Code Online (Sandbox Code Playgroud)
(删除with并添加secrets)
参考:重用工作流程 - example-caller-workflow
| 归档时间: |
|
| 查看次数: |
8476 次 |
| 最近记录: |