pr-review-hack.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. name: '[Support] PR review comment trigger'
  6. on:
  7. workflow_run:
  8. workflows:
  9. - '\[Support\] PR review comment card movements'
  10. types:
  11. - completed
  12. permissions: {}
  13. jobs:
  14. pr-info:
  15. runs-on: ubuntu-latest
  16. permissions:
  17. pull-requests: read
  18. actions: read
  19. outputs:
  20. author: ${{ steps.get-info.outputs.author }}
  21. actor: ${{ steps.get-info.outputs.actor }}
  22. labels: ${{ steps.get-info.outputs.labels }}
  23. resource_url: ${{ steps.get-info.outputs.resource_url }}
  24. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  25. steps:
  26. - id: get-info
  27. env:
  28. GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
  29. run: |
  30. actor="${{ github.event.workflow_run.actor.login }}"
  31. download_url="$(gh api "${{ github.event.workflow_run.artifacts_url }}" | jq -cr '.artifacts[] | select(.name == "pull_request_number") | .archive_download_url')"
  32. curl -sSL -o pull_request_number.zip -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: Bearer $GITHUB_TOKEN" $download_url
  33. unzip pull_request_number.zip
  34. pull_request_number=$(cat pull_request_number)
  35. pull_request="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}")"
  36. author="$(echo $pull_request | jq -cr '.user.login')"
  37. author_association="$(echo $pull_request | jq -cr '.author_association')"
  38. labels="$(echo $pull_request | jq -cr '[.labels[].name]')"
  39. resource_url="$(echo $pull_request | jq -cr '.html_url')"
  40. echo "::notice:: Managing PR #${pull_request_number}"
  41. echo "actor=${actor}" >> $GITHUB_OUTPUT
  42. echo "author=${author}" >> $GITHUB_OUTPUT
  43. echo "author_association=${author_association}" >> $GITHUB_OUTPUT
  44. echo "labels=${labels}" >> $GITHUB_OUTPUT
  45. echo "resource_url=${resource_url}" >> $GITHUB_OUTPUT
  46. call-pr-review-comment:
  47. uses: bitnami/support/.github/workflows/pr-review-comment.yml@main
  48. needs: pr-info
  49. permissions:
  50. contents: read
  51. secrets: inherit
  52. with:
  53. author: ${{ needs.pr-info.outputs.author }}
  54. actor: ${{ needs.pr-info.outputs.actor }}
  55. labels: ${{ needs.pr-info.outputs.labels }}
  56. resource_url: ${{ needs.pr-info.outputs.resource_url }}