printer-linter-pr-post.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. - uses: actions/checkout@v3
  40. with:
  41. repository: ${{ env.pr_head_repo }}
  42. ref: ${{ env.pr_head_ref }}
  43. persist-credentials: false
  44. - name: Redownload analysis results
  45. uses: actions/github-script@v3.1.0
  46. with:
  47. script: |
  48. let artifacts = await github.actions.listWorkflowRunArtifacts({
  49. owner: context.repo.owner,
  50. repo: context.repo.repo,
  51. run_id: ${{github.event.workflow_run.id }},
  52. });
  53. let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  54. return artifact.name == "printer-linter-result"
  55. })[0];
  56. let download = await github.actions.downloadArtifact({
  57. owner: context.repo.owner,
  58. repo: context.repo.repo,
  59. artifact_id: matchArtifact.id,
  60. archive_format: "zip",
  61. });
  62. let fs = require("fs");
  63. fs.writeFileSync("${{github.workspace}}/printer-linter-result.zip", Buffer.from(download.data));
  64. - name: Extract analysis results
  65. run: |
  66. mkdir printer-linter-result
  67. unzip printer-linter-result.zip -d printer-linter-result
  68. - name: Run clang-tidy-pr-comments action
  69. uses: platisd/clang-tidy-pr-comments@bc0bb7da034a8317d54e7fe1e819159002f4cc40
  70. with:
  71. github_token: ${{ secrets.GITHUB_TOKEN }}
  72. clang_tidy_fixes: printer-linter-result/fixes.yml
  73. pull_request_id: ${{ env.pr_id }}
  74. request_changes: true