如何获取 github 操作步骤的 stdout 和 stderr

问题描述 投票:0回答:1

我有一份工作,有一个名为“Terraform Plan”的步骤,ID 为“plan”。我想打印此步骤的标准输出和标准错误。但不幸的是我无法获取该信息。

回显 ${{ toJSON(steps.plan) }}

  echo {
    "outputs": {
      "tfplan_identifier": "tfplan-expected"
    },
    "outcome": "failure",
    "conclusion": "success"
  }

如何获取标准输出和标准错误。

${{ steps.plan.outputs.stderr }}
返回 null。

  plan:
    needs: [conflict, format, validate, lint, security]
    name: plan
    runs-on: ubuntu-latest
    outputs:
      tfplan_identifier: ${{ steps.plan.outputs.tfplan_identifier }}
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v2
      with:
        aws-region: us-east-2
        aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }}
    - name: Setup Terraform
      uses: hashicorp/setup-terraform@v2
      with:
        terraform_version: 1.3.7
        terraform_wrapper: false
    - name: Terraform Init
      id: init
      run: terraform init -backend-config=prod.s3.tfbackend
    - name: Terraform Workspace
      run: terraform workspace select prod || terraform workspace new prod 
    - name: Terraform Plan
      id: plan
      continue-on-error: true
      run: |
        tfplan_identifier=tfplan-expected
        echo "tfplan_identifier=$tfplan_identifier" >> $GITHUB_OUTPUT
        terraform plan -var-file="prod.tfvars" -input=false -no-color -out=${tfplan_identifier}
        terraform show -no-color tfplan-actual > plan.log
    - name: Output
      run: |
        echo ${{ toJSON(steps.plan) }}
        echo ${{ steps.plan.outputs.stderr }}

    ```

github github-actions
1个回答
0
投票

请将其更改为以下块,

  • 名称:设置 Terraform 使用:hashicorp/setup-terraform@v3 和: terraform_version:“〜> 1.7.5” terraform_wrapper:true
© www.soinside.com 2019 - 2024. All rights reserved.