|
1 | 1 | name: 'Quality Monitor Comment PR' |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
| 4 | + workflow_run: |
| 5 | + workflows: ['Quality Monitor', 'Dependency Check'] |
| 6 | + types: [completed] |
5 | 7 |
|
6 | 8 | permissions: |
7 | | - contents: read |
8 | 9 | actions: read |
| 10 | + contents: read |
9 | 11 | pull-requests: write |
10 | 12 | checks: write |
11 | 13 |
|
12 | 14 | jobs: |
13 | 15 | comment: |
| 16 | + if: ${{ github.event.workflow_run.event == 'pull_request' }} |
14 | 17 | runs-on: ubuntu-latest |
15 | 18 | name: Comment on PR |
16 | 19 |
|
17 | 20 | steps: |
| 21 | + - name: Extract PR number and SHA |
| 22 | + id: pr |
| 23 | + run: | |
| 24 | + pr_number='${{ github.event.workflow_run.pull_requests[0].number }}' |
| 25 | + echo "number=$pr_number" >> "$GITHUB_OUTPUT" |
| 26 | + sha='${{ github.event.workflow_run.head_sha }}' |
| 27 | + echo "sha=$sha" >> "$GITHUB_OUTPUT" |
18 | 28 | - name: Checkout PR |
19 | 29 | uses: actions/checkout@v6 |
20 | 30 | with: |
21 | | - ref: ${{ github.event.pull_request.head.sha }} |
22 | | - |
| 31 | + ref: ${{ steps.pr.outputs.sha }} |
23 | 32 | - name: Install jq and unzip |
24 | 33 | run: sudo apt-get update && sudo apt-get install -y jq unzip |
25 | | - |
| 34 | + - name: Prepare environment |
| 35 | + env: |
| 36 | + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |
| 37 | + REPO: ${{ github.repository }} |
| 38 | + TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + run: | |
| 40 | + echo "HEAD_SHA=$HEAD_SHA" |
| 41 | + echo "REPO=$REPO" |
26 | 42 | - name: Fetch reports from dependency check and quality monitor workflows |
27 | 43 | env: |
28 | 44 | REPO: ${{ github.repository }} |
29 | | - HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 45 | + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |
30 | 46 | TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | 47 | OTHER_WORKFLOWS: "quality-monitor-build.yml,dependency-check.yml" |
32 | 48 | ARTIFACT_NAMES: "quality-reports,dependency-report" |
33 | | - ALLOWED_EVENTS: "pull_request,pull_request_target" |
34 | | - RETRIES: 60 |
| 49 | + RETRIES: 30 |
35 | 50 | SLEEP_SEC: 10 |
36 | 51 | run: | |
37 | 52 | chmod +x ./.github/scripts/fetch-artifacts.sh |
38 | 53 | ./.github/scripts/fetch-artifacts.sh |
39 | | -
|
40 | 54 | - name: List downloaded reports |
41 | 55 | run: | |
42 | 56 | mkdir -p reports/target |
43 | 57 | mv artifacts/*/target/* reports/target |
44 | 58 | ls -la reports/target/* || true |
45 | | -
|
46 | 59 | - name: Read Quality Monitor Configuration |
47 | 60 | id: quality-monitor |
48 | 61 | run: echo "json=$(jq -c . .github/quality-monitor-pr.json)" >> "$GITHUB_OUTPUT" |
49 | | - |
50 | 62 | - name: Read Quality Gates Configuration |
51 | 63 | id: quality-gates |
52 | 64 | run: echo "json=$(jq -c . .github/quality-gates-pr.json)" >> "$GITHUB_OUTPUT" |
53 | | - |
54 | 65 | - name: Run Quality Monitor and Comment on PR |
55 | 66 | uses: uhafner/quality-monitor@v4 |
56 | 67 | with: |
57 | | - sha: ${{ github.event.pull_request.head.sha }} |
| 68 | + sha: ${{ steps.pr.outputs.sha }} |
58 | 69 | config: ${{ steps.quality-monitor.outputs.json }} |
59 | 70 | quality-gates: ${{ steps.quality-gates.outputs.json }} |
60 | | - pr-number: ${{ github.event.pull_request.number }} |
| 71 | + pr-number: ${{ steps.pr.outputs.number }} |
61 | 72 | comments-strategy: REMOVE |
62 | 73 | show-headers: true |
63 | 74 | title-metric: none |
0 commit comments