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