Skip to content

Commit 065dc1d

Browse files
authored
Publish only readmes that are changed in the commit
Signed-off-by: Jitendra Patil <jitendra.patil@intel.com>
1 parent b6216ea commit 065dc1d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/dockerhub-description.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,27 @@ jobs:
2323
outputs:
2424
matrix: ${{ steps.set-matrix.outputs.matrix }}
2525
steps:
26-
- name: Harden Runner
27-
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
28-
with:
29-
egress-policy: audit
3026
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
31-
- name: Set matrix data
27+
with:
28+
fetch-depth: 2
29+
- name: Set Matrix data
3230
id: set-matrix
33-
run: echo "matrix=$(jq -c . < .github/dockerhub-readmes.json)" >> $GITHUB_OUTPUT
31+
run: |
32+
# Get the list of files changed in the latest commit(s)
33+
changed_files=$(git diff --name-only HEAD~1 ${{ github.sha }} | sed 's|^|./|' | jq -R . | jq -s .)
34+
echo "Changed files: $changed_files"
35+
36+
# If there are changed files, filter the JSON using jq
37+
matrix=$(jq -c --argjson changed "$changed_files" \
38+
'.readmes |= map(select(.fname as $fname | any($changed[]; . == $fname)))' \
39+
.github/dockerhub-readmes.json)
40+
echo "Filtered matrix:"
41+
echo $matrix
42+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
3443
publish-dockerhub-description:
3544
runs-on: ${{ github.repository_owner == 'intel' && 'intel-ubuntu-latest' || 'ubuntu-latest' }}
3645
needs: setup-matrix
46+
if: ${{ needs.setup-matrix.outputs.matrix != '{"readmes":[]}' }}
3747
strategy:
3848
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
3949
fail-fast: false

0 commit comments

Comments
 (0)