Skip to content

Commit 32e974b

Browse files
committed
Move reference report download step to included action
1 parent 50da566 commit 32e974b

2 files changed

Lines changed: 87 additions & 42 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: 'Download Reference Reports'
2+
description: 'Downloads quality reports from the main branch and extracts run/commit URLs'
3+
4+
inputs:
5+
artifact-name:
6+
description: 'Name of the artifact to download'
7+
required: false
8+
default: 'quality-reports'
9+
path:
10+
description: 'Path to download artifact to'
11+
required: false
12+
default: 'reference-reports'
13+
repository:
14+
description: 'GitHub repository (owner/repo)'
15+
required: true
16+
workflow:
17+
description: 'Workflow file to download artifacts from'
18+
required: false
19+
default: 'quality-monitor-build.yml'
20+
21+
outputs:
22+
commit_url:
23+
description: 'URL of the reference commit'
24+
value: ${{ steps.reference-info.outputs.commit_url }}
25+
head_sha:
26+
description: 'Commit SHA of the reference workflow run'
27+
value: ${{ steps.reference-info.outputs.head_sha }}
28+
run_id:
29+
description: 'Run ID of the reference workflow run'
30+
value: ${{ steps.reference-info.outputs.run_id }}
31+
run_number:
32+
description: 'Run number of the reference workflow run'
33+
value: ${{ steps.reference-info.outputs.run_number }}
34+
run_url:
35+
description: 'URL of the reference workflow run'
36+
value: ${{ steps.reference-info.outputs.run_url }}
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- name: Download reference reports from main branch
42+
id: download-reference
43+
uses: dawidd6/action-download-artifact@v21
44+
with:
45+
branch: main
46+
check_artifacts: true
47+
if_no_artifact_found: ignore
48+
name: ${{ inputs.artifact-name }}
49+
path: ${{ inputs.path }}
50+
workflow: ${{ inputs.workflow }}
51+
52+
- name: Display reference artifact info
53+
id: reference-info
54+
shell: bash
55+
run: |
56+
echo "Artifact details: ${{ steps.download-reference.outputs.artifacts }}"
57+
run_id=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.id // "unknown"')
58+
run_number=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.run_number // "unknown"')
59+
head_sha=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.head_sha // "unknown"')
60+
echo "Downloaded artifact from Run ID: $run_id"
61+
echo "Downloaded artifact from Run Number: $run_number"
62+
echo "Downloaded artifact from Commit SHA: $head_sha"
63+
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
64+
echo "run_number=$run_number" >> "$GITHUB_OUTPUT"
65+
echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT"
66+
67+
if [ "$run_id" != "unknown" ]; then
68+
run_url="https://github.com/${{ inputs.repository }}/actions/runs/$run_id"
69+
echo "Run URL: $run_url"
70+
echo "run_url=$run_url" >> "$GITHUB_OUTPUT"
71+
fi
72+
73+
if [ "$head_sha" != "unknown" ]; then
74+
commit_url="https://github.com/${{ inputs.repository }}/commit/$head_sha"
75+
echo "Commit URL: $commit_url"
76+
echo "commit_url=$commit_url" >> "$GITHUB_OUTPUT"
77+
fi
78+

.github/workflows/quality-monitor-comment-pr.yml

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,14 @@ jobs:
2020
steps:
2121
- name: Checkout PR
2222
uses: actions/checkout@v6
23-
- name: Download reference reports from main branch
24-
id: download-reference
25-
uses: dawidd6/action-download-artifact@v21
23+
- name: Install jq and unzip
24+
run: sudo apt-get update && sudo apt-get install -y jq unzip
25+
- name: Download reference reports from main branch pipeline run
26+
id: reference
27+
uses: ./.github/actions/download-reference
2628
with:
27-
workflow: quality-monitor-build.yml
28-
branch: main
29-
name: quality-reports
30-
path: reference-reports
31-
check_artifacts: true
32-
if_no_artifact_found: ignore
33-
- name: Display reference artifact info
34-
id: reference-info
35-
run: |
36-
echo "Artifact details: ${{ steps.download-reference.outputs.artifacts }}"
37-
run_id=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.id // "unknown"')
38-
run_number=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.run_number // "unknown"')
39-
head_sha=$(echo '${{ steps.download-reference.outputs.artifacts }}' | jq -r '.[0].workflow_run.head_sha // "unknown"')
40-
echo "Downloaded artifact from Run ID: $run_id"
41-
echo "Downloaded artifact from Run Number: $run_number"
42-
echo "Downloaded artifact from Commit SHA: $head_sha"
43-
44-
if [ "$run_id" != "unknown" ]; then
45-
run_url="https://github.com/${{ github.repository }}/actions/runs/$run_id"
46-
echo "Run URL: $run_url"
47-
echo "run_url=$run_url" >> "$GITHUB_ENV"
48-
echo "run_url=$run_url" >> "$GITHUB_OUTPUT"
49-
fi
50-
51-
if [ "$head_sha" != "unknown" ]; then
52-
commit_url="https://github.com/${{ github.repository }}/commit/$head_sha"
53-
echo "Commit URL: $commit_url"
54-
echo "commit_url=$commit_url" >> "$GITHUB_ENV"
55-
echo "commit_url=$commit_url" >> "$GITHUB_OUTPUT"
56-
fi
57-
58-
echo "run_id=$run_id" >> "$GITHUB_ENV"
59-
echo "run_number=$run_number" >> "$GITHUB_ENV"
60-
echo "head_sha=$head_sha" >> "$GITHUB_ENV"
61-
- name: Fetch reports from dependency check and quality monitor workflows
29+
repository: ${{ github.repository }}
30+
- name: Download current reports from dependency check and quality monitor workflows
6231
env:
6332
REPO: ${{ github.repository }}
6433
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
@@ -84,8 +53,6 @@ jobs:
8453
fi
8554
echo "PR number from reports/pr-number.txt: $pr_number"
8655
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
87-
- name: Install jq and unzip
88-
run: sudo apt-get update && sudo apt-get install -y jq unzip
8956
- name: Prepare environment
9057
env:
9158
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
@@ -107,8 +74,8 @@ jobs:
10774
config: ${{ steps.quality-monitor.outputs.json }}
10875
quality-gates: ${{ steps.quality-gates.outputs.json }}
10976
pr-number: ${{ steps.pr.outputs.number }}
110-
reference-commit-url: ${{ steps.reference-info.outputs.commit_url }}
111-
reference-run-url: ${{ steps.reference-info.outputs.run_url }}
77+
reference-commit-url: ${{ steps.reference.outputs.commit_url }}
78+
reference-run-url: ${{ steps.reference.outputs.run_url }}
11279
comments-strategy: REMOVE
11380
show-headers: true
11481
title-metric: none

0 commit comments

Comments
 (0)