Skip to content

Commit 44147e4

Browse files
committed
refactor(workflow): simplify markdown update process by using changed-files action
1 parent 709c0d1 commit 44147e4

File tree

2 files changed

+8
-43
lines changed

2 files changed

+8
-43
lines changed

.github/workflows/on-markdown-update.yml

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,13 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
25-
- name: Define file masks
26-
id: define-file-masks
27-
run: |
28-
echo "file_masks='README.md'" >> $GITHUB_ENV
29-
30-
- name: Get changed files
24+
- name: Get all markdown files
3125
id: changed-markdown-files
32-
run: |
33-
# Initialize variables
34-
changed_files=""
35-
deleted_files=""
36-
any_changes="false"
37-
38-
# Loop through each file mask and check for changes
39-
for mask in ${{ env.file_masks }}; do
40-
# Get the list of changed files for the current mask
41-
current_changed_files=$(git diff --name-status ${{ github.event.before }} ${{ github.event.after }} | grep '^[AM]' | grep "${mask}" | awk '{print $2}' | xargs)
42-
# Get the list of deleted files for the current mask
43-
current_deleted_files=$(git diff --name-status ${{ github.event.before }} ${{ github.event.after }} | grep '^D' | grep "${mask}" | awk '{print $2}' | xargs)
44-
# Check if there are any changes for the current mask
45-
current_any_changed=$(git diff --name-status ${{ github.event.before }} ${{ github.event.after }} | grep "${mask}" | wc -l)
46-
47-
# Append the current changed files to the overall list
48-
if [ -n "$current_changed_files" ]; then
49-
changed_files="$changed_files $current_changed_files"
50-
fi
51-
52-
# Append the current deleted files to the overall list
53-
if [ -n "$current_deleted_files" ]; then
54-
deleted_files="$deleted_files $current_deleted_files"
55-
fi
56-
57-
# Set any_changes to true if there are any changes for the current mask
58-
if [ "$current_any_changed" -gt 0 ]; then
59-
any_changes="true"
60-
fi
61-
done
62-
63-
# Set the outputs
64-
echo "changed_files=${changed_files}" >> $GITHUB_OUTPUT
65-
echo "deleted_files=${deleted_files}" >> $GITHUB_OUTPUT
66-
echo "any_changed=${any_changes}" >> $GITHUB_OUTPUT
26+
uses: chemodun/[email protected]
27+
with:
28+
# Avoid using single or double quotes for multiline patterns
29+
files: |
30+
README.md
6731
6832
- name: Install python3
6933
if: steps.changed-markdown-files.outputs.any_changed == 'true'
@@ -77,7 +41,7 @@ jobs:
7741
- name: Process *.md changes
7842
if: steps.changed-markdown-files.outputs.any_changed == 'true'
7943
env:
80-
CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.changed_files }}
44+
CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
8145
DELETED_FILES: ${{ steps.changed-markdown-files.outputs.deleted_files }}
8246
run: |
8347
git config user.name "Chem O'Dun"

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"aiscripts",
1111
"assignedcontrolled",
1212
"bbcode",
13+
"chemodun",
1314
"defaultorder",
1415
"EGOSOFT",
1516
"energycells",

0 commit comments

Comments
 (0)