pr-review-hack.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright Broadcom, Inc. All Rights Reserved.
  2. # SPDX-License-Identifier: APACHE-2.0
  3. # This is a hack to run reusable workflows in the main repo context and not from the forked repository.
  4. # We this hack we can use secrets configured in the organization.
  5. # NOTE: This workflow is maintained in the https://github.com/bitnami/support repository
  6. name: '[Support] PR review comment trigger'
  7. on:
  8. workflow_run:
  9. workflows:
  10. - '\[Support\] PR review comment card movements'
  11. types:
  12. - completed
  13. permissions: {}
  14. jobs:
  15. pr-info:
  16. runs-on: ubuntu-latest
  17. permissions:
  18. pull-requests: read
  19. actions: read
  20. outputs:
  21. author: ${{ steps.get-info.outputs.author }}
  22. actor: ${{ steps.get-info.outputs.actor }}
  23. review_state: ${{ steps.get-info.outputs.review_state }}
  24. labels: ${{ steps.get-info.outputs.labels }}
  25. resource_url: ${{ steps.get-info.outputs.resource_url }}
  26. if: ${{ github.repository_owner == 'bitnami' && github.event.workflow_run.conclusion == 'success' }}
  27. steps:
  28. - id: get-info
  29. env:
  30. GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
  31. run: |
  32. actor="${{ github.event.workflow_run.actor.login }}"
  33. download_url="$(gh api "${{ github.event.workflow_run.artifacts_url }}" | jq -cr '.artifacts[] | select(.name == "pull_request_info.json") | .archive_download_url')"
  34. curl -sSL -o pull_request_info.zip -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: Bearer $GITHUB_TOKEN" $download_url
  35. unzip pull_request_info.zip
  36. pull_request_number="$(jq -cr '.issue.number' pull_request_info.json)"
  37. issue_review_state="$(jq -cr '.review.state' pull_request_info.json)"
  38. pull_request="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}")"
  39. author="$(echo $pull_request | jq -cr '.user.login')"
  40. author_association="$(echo $pull_request | jq -cr '.author_association')"
  41. labels="$(echo $pull_request | jq -cr '[.labels[].name]')"
  42. resource_url="$(echo $pull_request | jq -cr '.html_url')"
  43. echo "::notice:: Managing PR #${pull_request_number}"
  44. echo "actor=${actor}" >> $GITHUB_OUTPUT
  45. echo "author=${author}" >> $GITHUB_OUTPUT
  46. echo "author_association=${author_association}" >> $GITHUB_OUTPUT
  47. echo "review_state=${issue_review_state}" >> $GITHUB_OUTPUT
  48. echo "labels=${labels}" >> $GITHUB_OUTPUT
  49. echo "resource_url=${resource_url}" >> $GITHUB_OUTPUT
  50. call-pr-review-comment:
  51. uses: bitnami/support/.github/workflows/pr-review-comment.yml@main
  52. needs: pr-info
  53. permissions:
  54. contents: read
  55. secrets: inherit
  56. with:
  57. author: ${{ needs.pr-info.outputs.author }}
  58. actor: ${{ needs.pr-info.outputs.actor }}
  59. labels: ${{ needs.pr-info.outputs.labels }}
  60. review_state: ${{ needs.pr-info.outputs.review_state }}
  61. resource_url: ${{ needs.pr-info.outputs.resource_url }}