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