让我们以这个例子为例,在Github的文档中找到复合操作:
name: 'Hello World'
description: 'Greet someone'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
runs:
using: "composite"
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
shell: bash
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
shell: bash
- run: ${{ github.action_path }}/goodbye.sh
shell: bash如何在调用此操作的外部工作流中使用特定的输出random-number?我尝试了下面的代码片段,但目前似乎工作流无法从操作中读取输出变量,因为它只是空的-“输出-”。
jobs:
test-job:
runs-on: self-hosted
steps:
- name: Call Hello World
id: hello-world
uses: actions/hello-world-action@v1
- name: Comment
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Output - ${{ steps.hello-world.outputs.random-number.value }}'
})发布于 2021-04-27 13:42:47
除了一个细节之外,我的尝试似乎是正确的:
而不是:
${{ steps.hello-world.outputs.random-number.value }}应该在没有.value的情况下引用
${{ steps.hello-world.outputs.random-number}}现在起作用了。
https://stackoverflow.com/questions/67283976
复制相似问题