Newer
Older
dub_jkp / .github / workflows / pr_info_post.yml
@WebFreak001 WebFreak001 on 9 Mar 2023 1 KB fix pr_info_post file paths
  1. name: PR Info (comment)
  2.  
  3. on:
  4. workflow_run:
  5. workflows: ["PR Info"]
  6. types:
  7. - completed
  8.  
  9. jobs:
  10. comment:
  11. name: PR Info
  12. runs-on: ubuntu-20.04
  13. if: >
  14. github.event.workflow_run.event == 'pull_request' &&
  15. github.event.workflow_run.conclusion == 'success'
  16. steps:
  17. # from https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
  18. - name: 'Download artifact'
  19. uses: actions/github-script@v3.1.0
  20. with:
  21. script: |
  22. var artifacts = await github.actions.listWorkflowRunArtifacts({
  23. owner: context.repo.owner,
  24. repo: context.repo.repo,
  25. run_id: ${{github.event.workflow_run.id }},
  26. });
  27. var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  28. return artifact.name == "pr"
  29. })[0];
  30. var download = await github.actions.downloadArtifact({
  31. owner: context.repo.owner,
  32. repo: context.repo.repo,
  33. artifact_id: matchArtifact.id,
  34. archive_format: 'zip',
  35. });
  36. var fs = require('fs');
  37. fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
  38. - run: unzip pr.zip
  39.  
  40. - name: Set variable
  41. run: |
  42. PR_ID=$(cat ./NR)
  43. echo "PR_ID=$PR_ID" >> $GITHUB_ENV
  44.  
  45. - name: Update GitHub comment
  46. uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd
  47. with:
  48. path: ./comment.txt
  49. number: ${{ env.PR_ID }}