Skip to content

Commit 7fa3400

Browse files
Optimize readme publish workflow (#484)
Signed-off-by: Jitendra Patil <jitendra.patil@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b6216ea commit 7fa3400

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/dockerhub-description.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,24 @@ jobs:
2828
with:
2929
egress-policy: audit
3030
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
31-
- name: Set matrix data
31+
with:
32+
fetch-depth: 2
33+
- name: Set Matrix data
3234
id: set-matrix
33-
run: echo "matrix=$(jq -c . < .github/dockerhub-readmes.json)" >> $GITHUB_OUTPUT
35+
run: |
36+
# Get the list of files changed in the latest commit(s)
37+
changed_files=$(git diff --name-only HEAD~1 ${{ github.sha }} | sed 's|^|./|' | jq -R . | jq -s .)
38+
echo "Changed files: $changed_files"
39+
40+
# If there are changed files, filter the JSON using jq
41+
matrix=$(jq -c --argjson changed "$changed_files" \
42+
'.readmes |= map(select(.fname as $fname | any($changed[]; . == $fname)))' \
43+
.github/dockerhub-readmes.json)
44+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
3445
publish-dockerhub-description:
3546
runs-on: ${{ github.repository_owner == 'intel' && 'intel-ubuntu-latest' || 'ubuntu-latest' }}
3647
needs: setup-matrix
48+
if: ${{ needs.setup-matrix.outputs.matrix != '{"readmes":[]}' }}
3749
strategy:
3850
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
3951
fail-fast: false

0 commit comments

Comments
 (0)