这与所问的类似here https://stackoverflow.com/questions/61256824/how-to-pass-the-output-of-a-bash-command-to-github-action-parameter但有更多的解释和对最新答案的渴望(答案使用 set-env ,现已弃用)
假设我有以下 github 操作 yaml:
name: pull-request-pipeline
on: [pull_request]
jobs:
deploy-to-dev-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout action
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Update API gateway definitions
run: |
aws apigateway put-rest-api --rest-api-id xxxxxxxx --mode merge --body 'file://SummitApi.yaml'
- name: Get and store current deploymentId
run: |
OLD_DEPLOYMENT_ID=$(aws apigateway get-stage --rest-api-id xxxxxxxx --stage-name dev --query deploymentId --output text)
echo '::set-output name=OLD_DEPLOYMENT_ID::$OLD_DEPLOYMENT_ID'
id: old-deployment-id
- name: Echo old deployment before deploy
run: |
echo ${{ steps.old-deployment-id.outputs.OLD_DEPLOYMENT_ID }}
- name: Deploy to dev stage
run: |
aws apigateway create-deployment --rest-api xxxxxxxx --stage-name dev
- name: Echo old deployment id after deploy
run: |
echo ${{ steps.old-deployment-id.outputs.OLD_DEPLOYMENT_ID }}
当它运行时,它会产生以下结果:
当采取另一种方法时,特别改变Get and store current deploymentId
步骤:
- name: Get and store current deploymentId
run: |
OLD_DEPLOYMENT_ID=$(aws apigateway get-stage --rest-api-id xxxxxxxx --stage-name dev --query deploymentId --output text)
echo '::set-output name=OLD_DEPLOYMENT_ID::$OLD_DEPLOYMENT_ID'
id: old-deployment-id
我得到以下信息:
看起来它将操作的输出值设置为未评估的定义$OLD_DEPLOYMENT
or $(aws apigateway get-stage --rest-api-id xxxxxxxx --stage-name dev --query deploymentId --output text)
。我希望能够存储评估的定义的值,或者在本例中存储来自 cmd 的实际部署 ID$(aws apigateway get-stage --rest-api-id xxxxxxxx --stage-name dev --query deploymentId --output text)
。关于如何使用 github 操作来做到这一点有什么想法吗?
参考:
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)