Skip to content

Commit ca0a2b4

Browse files
authored
Merge pull request #14537 from ggbecker/fix-compare-ds-9
Fix compare DS job
2 parents 015f778 + 90559e6 commit ca0a2b4

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

.github/workflows/compare-ds-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
with:
5050
path: 'output.json'
5151
prop_path: 'product'
52-
- name: Build product ${{ github.base_ref }} (${{ steps.fork_point.outputs.FORK_POINT }})
52+
- name: Build product PR ${{ github.event.pull_request.head.sha }}
5353
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
5454
run: ./build_product ${{steps.product.outputs.prop}} --datastream-only
5555
- name: Create Artifact
@@ -63,7 +63,7 @@ jobs:
6363
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
6464
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4
6565
with:
66-
name: pr-artifacts-${{ github.event.pull_request.head.sha }}
66+
name: pr-artifacts
6767
retention-days: 1
6868
path: artifacts.tar.gz
6969
- name: Save PR info

.github/workflows/compare-ds.yaml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ permissions:
88
pull-requests: write
99
contents: read
1010
actions: read
11+
checks: write
1112
jobs:
12-
build-content:
13+
compare_ds_job:
1314
name: Generate Diff
1415
runs-on: ubuntu-latest
1516
container:
@@ -30,19 +31,32 @@ jobs:
3031
id: pr_info
3132
run: |
3233
PR_NUMBER=$(cat pr-info/pr-number.txt)
34+
PR_SHA=$(cat pr-info/pr-sha.txt)
3335
BASE_BRANCH=$(cat pr-info/base-branch.txt)
3436
FORK_POINT=$(cat pr-info/fork-point.txt)
3537
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
38+
echo "pr_sha=${PR_SHA}" >> $GITHUB_OUTPUT
3639
echo "base_branch=${BASE_BRANCH}" >> $GITHUB_OUTPUT
3740
echo "fork_point=${FORK_POINT}" >> $GITHUB_OUTPUT
3841
echo "PR Number: ${PR_NUMBER}"
42+
echo "PR SHA: ${PR_SHA}"
3943
echo "Base Branch: ${BASE_BRANCH}"
4044
echo "Fork Point: ${FORK_POINT}"
41-
- name: Checkout master
45+
- name: Create GitHub check run
46+
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2.0.0
47+
id: create_check
48+
with:
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
name: Compare DS
51+
status: in_progress
52+
sha: ${{ steps.pr_info.outputs.pr_sha }}
53+
output: |
54+
{"summary":"Compare DS started. Job: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."}
55+
- name: Checkout forking point (${{ steps.pr_info.outputs.fork_point }})
4256
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
4357
with:
4458
repo: ComplianceAsCode/content
45-
ref: master
59+
ref: ${{ steps.pr_info.outputs.fork_point }}
4660
fetch-depth: 0
4761
# https://github.com/actions/checkout/issues/766
4862
- name: Set git safe directory
@@ -75,7 +89,7 @@ jobs:
7589
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
7690
with:
7791
github-token: ${{ secrets.GITHUB_TOKEN }}
78-
name: pr-artifacts-${{ github.event.workflow_run.head_sha }}
92+
name: pr-artifacts
7993
path: pr_artifacts
8094
run-id: ${{ github.event.workflow_run.id }}
8195
- name: Unpack built artifacts
@@ -158,7 +172,7 @@ jobs:
158172
token: ${{ secrets.GITHUB_TOKEN }}
159173
- name: Compare Ansible playbook shell commands
160174
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
161-
run: utils/ansible_shell_diff.py ssg-${{steps.product.outputs.prop}}-ds.xml build/ssg-${{steps.product.outputs.prop}}-ds.xml | tee diff.log
175+
run: utils/ansible_shell_diff.py build/ssg-${{steps.product.outputs.prop}}-ds.xml pr_artifacts/artifacts/ssg-${{steps.product.outputs.prop}}-ds.xml | tee diff.log
162176
env:
163177
PYTHONPATH: ${{ github.workspace }}
164178
- name: Test if there are Ansible shell module changes
@@ -188,3 +202,13 @@ jobs:
188202
type: delete
189203
comment_id: ${{ steps.shell_diff.outputs.comment-id }}
190204
token: ${{ secrets.GITHUB_TOKEN }}
205+
- name: Compare DS
206+
if: always()
207+
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2.0.0
208+
with:
209+
token: ${{ secrets.GITHUB_TOKEN }}
210+
conclusion: ${{ job.status }}
211+
check_id: ${{ steps.create_check.outputs.check_id }}
212+
sha: ${{ steps.pr_info.outputs.pr_sha }}
213+
output: |
214+
{"summary":"Compare DS completed. Job: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."}

0 commit comments

Comments
 (0)