Zam*_*ozo 7 github terraform github-actions cicd
我正在遵循 HashiCorp 的学习指南,了解如何设置 GitHub Actions 和 terraform。除了使用 Terraform 计划更新 PR 的步骤之外,一切都运行良好。
\n我遇到以下错误:
\n\nAn error occurred trying to start process \'/home/runner/runners/2.287.1/externals/node12/bin/node\' with working directory \'/home/runner/work/ccoe-aws-ou-scp-manage/ccoe-aws-ou-scp-manage\'. Argument list too long\n\n
Run Code Online (Sandbox Code Playgroud)\n我正在使用的代码是:
\n - uses: actions/github-script@0.9.0\n if: github.event_name == \'pull_request\'\n env:\n PLAN: "terraform\\n${{ steps.plan.outputs.stdout }}"\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n script: |\n const output = `#### Terraform Format and Style \\`${{ steps.fmt.outcome }}\\`\n #### Terraform Initialization \xe2\x9a\x99\xef\xb8\x8f\\`${{ steps.init.outcome }}\\`\n #### Terraform Plan \\`${{ steps.plan.outcome }}\\`\n <details><summary>Show Plan</summary>\n \\`\\`\\`${process.env.PLAN}\\`\\`\\`\n </details>\n *Pusher: @${{ github.actor }}, Action: \\`${{ github.event_name }}\\`*`;\n \n github.issues.createComment({\n issue_number: context.issue.number,\n owner: context.repo.owner,\n repo: context.repo.repo,\n body: output\n })\n
Run Code Online (Sandbox Code Playgroud)\n来自文档的清晰复制/粘贴:https://learn.hashicorp.com/tutorials/terraform/github-actions
\n我已经尝试过 \nactions/github-script 版本 5 和 6,但仍然存在同样的问题,但是当我复制粘贴该计划时,一切都很棒。如果我不使用输出变量并在正文中使用一些占位符文本,那么一切都很好。如果我只打印它,我可以看到 step.plan.outputs.stdout 是好的。
\n如果需要,我很乐意分享更多细节。
\n我也遇到了类似的问题。\n我似乎github-script
无法为太长的脚本提供参数。
参考:
\n我的答案:
\n - name: truncate terraform plan result\n run: |\n plan=$(cat <<\'EOF\'\n ${{ format(\'{0}{1}\', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}\n EOF\n )\n echo "${plan}" | grep -v \'Refreshing state\' >> $GITHUB_ENV\n echo "EOF" >> $GITHUB_ENV\n\n - name: create comment from plan result\n uses: actions/github-script@0.9.0\n if: github.event_name == \'pull_request\'\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n script: |\n const output = `#### Terraform Initialization \xe2\x9a\x99\xef\xb8\x8f\\`${{ steps.init.outcome }}\\`\n #### Terraform Plan \\`${{ steps.plan.outcome }}\\`\n \n <details><summary>Show Plan</summary>\n \n \\`\\`\\`\\n\n ${ process.env.PLAN }\n \\`\\`\\`\n \n </details>\n \n *Pusher: @${{ github.actor }}, Action: \\`${{ github.event_name }}\\`, Working Directory: \\`${{ inputs.TF_WORK_DIR }}\\`, Workflow: \\`${{ github.workflow }}\\`*`;\n\n github.issues.createComment({\n issue_number: context.issue.number,\n owner: context.repo.owner,\n repo: context.repo.repo,\n body: output\n })```\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
5603 次 |
最近记录: |