printer-linter-pr-post.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: printer-linter-pr-post
  2. on:
  3. workflow_run:
  4. workflows: ["printer-linter-pr-diagnose"]
  5. types: [completed]
  6. jobs:
  7. clang-tidy-results:
  8. # Trigger the job only if the previous (insecure) workflow completed successfully
  9. if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Download analysis results
  13. uses: actions/github-script@v3.1.0
  14. with:
  15. script: |
  16. let artifacts = await github.actions.listWorkflowRunArtifacts({
  17. owner: context.repo.owner,
  18. repo: context.repo.repo,
  19. run_id: ${{github.event.workflow_run.id }},
  20. });
  21. let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  22. return artifact.name == "printer-linter-result"
  23. })[0];
  24. let download = await github.actions.downloadArtifact({
  25. owner: context.repo.owner,
  26. repo: context.repo.repo,
  27. artifact_id: matchArtifact.id,
  28. archive_format: "zip",
  29. });
  30. let fs = require("fs");
  31. fs.writeFileSync("${{github.workspace}}/printer-linter-result.zip", Buffer.from(download.data));
  32. - name: Set environment variables
  33. run: |
  34. mkdir printer-linter-result
  35. unzip printer-linter-result.zip -d printer-linter-result
  36. echo "pr_id=$(cat printer-linter-result/pr-id.txt)" >> $GITHUB_ENV
  37. echo "pr_head_repo=$(cat printer-linter-result/pr-head-repo.txt)" >> $GITHUB_ENV
  38. echo "pr_head_ref=$(cat printer-linter-result/pr-head-ref.txt)" >> $GITHUB_ENV
  39. if [[ -f "printer-linter-result/comment.md" ]]; then
  40. echo "commentFileExists=true" >> $GITHUB_ENV
  41. else
  42. echo "commentFileExists=false" >> $GITHUB_ENV
  43. fi
  44. - uses: actions/checkout@v3
  45. with:
  46. repository: ${{ env.pr_head_repo }}
  47. ref: ${{ env.pr_head_ref }}
  48. persist-credentials: false
  49. - name: Redownload analysis results
  50. uses: actions/github-script@v3.1.0
  51. with:
  52. script: |
  53. let artifacts = await github.actions.listWorkflowRunArtifacts({
  54. owner: context.repo.owner,
  55. repo: context.repo.repo,
  56. run_id: ${{github.event.workflow_run.id }},
  57. });
  58. let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  59. return artifact.name == "printer-linter-result"
  60. })[0];
  61. let download = await github.actions.downloadArtifact({
  62. owner: context.repo.owner,
  63. repo: context.repo.repo,
  64. artifact_id: matchArtifact.id,
  65. archive_format: "zip",
  66. });
  67. let fs = require("fs");
  68. fs.writeFileSync("${{github.workspace}}/printer-linter-result.zip", Buffer.from(download.data));
  69. - name: Extract analysis results
  70. run: |
  71. mkdir printer-linter-result
  72. unzip printer-linter-result.zip -d printer-linter-result
  73. - name: Run PR Comments
  74. if: env.commentFileExists == 'true'
  75. uses: peter-evans/create-or-update-comment@v4
  76. with:
  77. issue-number: ${{ env.pr_id }}
  78. body-path: 'printer-linter-result/comment.md'
  79. - name: Run clang-tidy-pr-comments action
  80. uses: platisd/clang-tidy-pr-comments@bc0bb7da034a8317d54e7fe1e819159002f4cc40
  81. with:
  82. github_token: ${{ secrets.GITHUB_TOKEN }}
  83. clang_tidy_fixes: printer-linter-result/fixes.yml
  84. pull_request_id: ${{ env.pr_id }}
  85. request_changes: true