在 GitHub 操作中获取“参数列表太长”
Getting `Argument list too long` in GitHub Actions
我正在按照 HashiCorp 的学习指南学习如何设置 GitHub Actions 和 terraform。除了使用 Terraform 计划更新 PR 的步骤之外,一切都运行很棒。
我遇到了以下错误:
An 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
我使用的代码是:
- uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style \`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan \`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`${process.env.PLAN}\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
来自文档的明确 COPY/Paste:https://learn.hashicorp.com/tutorials/terraform/github-actions
我试过
actions/github-script 版本 5 和 6 仍然是同样的问题,但是当我复制粘贴计划时一切都很好。如果我不使用输出变量并为正文使用一些占位符文本,一切都很好。我可以看到 step.plan.outputs.stdout 如果我只打印它就可以了。
如果需要,我很乐意分享更多详细信息。
我也遇到了类似的问题。
我似乎 github-script
无法为太长的脚本提供参数。
参考:
- https://github.com/robburger/terraform-pr-commenter/issues/6#issuecomment-826966670
- https://github.community/t/maximum-length-for-the-comment-body-in-issues-and-pr/148867
我的回答:
- name: truncate terraform plan result
run: |
plan=$(cat <<'EOF'
${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
EOF
)
echo "${plan}" | grep -v 'Refreshing state' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: create comment from plan result
uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan \`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${ process.env.PLAN }
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ inputs.TF_WORK_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})```
我正在按照 HashiCorp 的学习指南学习如何设置 GitHub Actions 和 terraform。除了使用 Terraform 计划更新 PR 的步骤之外,一切都运行很棒。
我遇到了以下错误:
An 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
我使用的代码是:
- uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style \`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan \`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`${process.env.PLAN}\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
来自文档的明确 COPY/Paste:https://learn.hashicorp.com/tutorials/terraform/github-actions
我试过 actions/github-script 版本 5 和 6 仍然是同样的问题,但是当我复制粘贴计划时一切都很好。如果我不使用输出变量并为正文使用一些占位符文本,一切都很好。我可以看到 step.plan.outputs.stdout 如果我只打印它就可以了。
如果需要,我很乐意分享更多详细信息。
我也遇到了类似的问题。
我似乎 github-script
无法为太长的脚本提供参数。
参考:
- https://github.com/robburger/terraform-pr-commenter/issues/6#issuecomment-826966670
- https://github.community/t/maximum-length-for-the-comment-body-in-issues-and-pr/148867
我的回答:
- name: truncate terraform plan result
run: |
plan=$(cat <<'EOF'
${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
EOF
)
echo "${plan}" | grep -v 'Refreshing state' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: create comment from plan result
uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan \`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${ process.env.PLAN }
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ inputs.TF_WORK_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})```