gpt4 book ai didi

github-actions - 如何在github actions中的其他运行命令中使用curl的响应

转载 作者:行者123 更新时间:2023-12-05 03:35:49 26 4
gpt4 key购买 nike

尝试从 curl 获取响应并在后续命令中使用它。不确定此处正确的语法应该是什么。

    - name: Get Token    
run: |
response = $(curl https://********* -header "Accept: application/json" -header "X-Username: ${{ secrets.USER_NAME }}" -header "X-Password: ${{ secrets.PASSWORD }}")
echo "response from curl= $response"

最佳答案

我能够使用下面的方法解决这个问题

  - name: GET all workspace
run: |
curl --location --request GET 'https://api.getpostman.com/workspaces' --header 'X-API-Key: ${{ secrets.API_TOKEN }}' -o workspaces.json

- name: read workspace id
id: workspace
run: echo "::set-output name=id::$(cat workspaces.json | jq -c '.workspaces[] | select(.name == "My Workspace").id')"

- name: print workspace id
run: echo ${{ steps.workspace.outputs.id }}

- name: GET api's in workspace
run: |
curl --location --request GET "https://api.getpostman.com/apis?workspace=${{ steps.workspace.outputs.id }}" --header 'X-API-Key: ${{ secrets.API_TOKEN }}' -o apis.json

- name: Read api id in workspace
id: api
run: echo "::set-output name=id::$(cat apis.json | jq -c '.apis[] | select(.name == "testing-service").id')"

- name: Print api id
run: echo ${{ steps.api.outputs.id }}

关于github-actions - 如何在github actions中的其他运行命令中使用curl的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69774778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com