【发布时间】:2021-04-24 07:33:09
【问题描述】:
我在 github 工作流作业中有一个步骤,如下所示:
- name: Create a workflow-started comment
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// create new comment on PR and get back the comment's nodeId for updating later.
const query = `mutation($pr_node_id:String!, $body:String!) {
addComment(input: {subjectId:$pr_node_id, body:$body}) {
commentEdge{
node {
id
}
}
}
}`;
const variables = {
pr_node_id:'${{steps.vars.outputs.pr-node-id}}',
body:'Workflow started!',
}
const result = await github.graphql(query, variables)
console.log(result)
它可以创建评论并输出结果:
{ addComment: { subject: { id: 'MDExOlB1bGxSZXF...N0NTd3Nzg2NDM5' } } }
我需要访问结果中的 id。有没有办法得到它?
【问题讨论】:
-
@xadm 仅当我想在作业之间共享数据时。看到眼前的答案,已经太迟了。
标签: graphql workflow github-script github-actions