Skip to content

Commit

Permalink
Artifacts are too cumbersome. try fixing the unescaped char
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored May 20, 2024
1 parent dacd80c commit b46c49c
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,32 @@ jobs:

- name: Terraform Plan
id: plan
run: terraform plan > plan.log
run: |
out="$(terraform plan -no-color)"
out="${out//'%'/'%25'}"
out="${out//$'\n'/'%0A'}"
out="${out//$'\r'/'%0D'}"
echo "::set-output name=plan::$out"
continue-on-error: true

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: terraform-plan
path: plan.log

- name: Post comment with artifact link
uses: actions/github-script@v6
- name: Post comment with Terraform plan
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const commentBody = `:rocket: Terraform plan has been created! [Download Artifact](${artifactUrl})`;
const output = `#### Terraform Plan 📖
\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`terraform
${{ steps.plan.outputs.plan }}
\`\`\`
</details>`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
body: output
});

0 comments on commit b46c49c

Please sign in to comment.