@@ -13,21 +13,39 @@ jobs:
1313 contents : read
1414 pull-requests : write
1515 steps :
16- - name : Get renamed/deleted files
17- id : renamed-deleted-files
18- uses : actions/checkout@v4
16+ - uses : actions/checkout@v4
17+ - id : changed-files
18+ # pin to a specific commit to ensure stability
19+ uses : tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
1920 with :
20- fetch-depth : 2
21-
22- - name : Check for deleted or renamed files
21+ separator : " ,"
22+ files : |
23+ *.txt
24+ - id : build-checklist-items
25+ env :
26+ RENAMED_FILES : ${{ steps.changed-files.outputs.renamed_files }}
27+ DELETED_FILES : ${{ steps.changed-files.outputs.deleted_files }}
2328 run : |
24- echo $(git remote --verbose)
25- echo $(pwd)
26- echo "Current Repository: ${{ github.repository }}"
27- echo "Current Branch: ${{ github.ref }}"
28- echo "Branch Name: ${{ github.ref_name }}"
29+ renamed_files_list=""
30+ deleted_files_list=""
31+
32+ #renamed files
33+ if ${{ steps.changed-files.outputs.renamed_files_count }} > 0
34+ for file in $RENAMED_FILES; do
35+ renamed_files_list+="<li>$file</li>"
36+ done
37+ fi
38+
39+ #deleted files
40+ if ${{ steps.changed-files.outputs.deleted_files_count }} > 0
41+ for file in $DELETED_FILES; do
42+ deleted_files_list+="<li>$file</li>"
43+ done
44+ fi
45+ echo "renamed_files=${renamed_files_list}" >> "$GITHUB_OUTPUT"
46+ echo "deleted_files=${deleted_files_list}" >> "$GITHUB_OUTPUT"
2947 - name : Update the PR Description
3048 uses : MongoCaleb/pr-description-action@master
3149 with :
32- content : " - [ ] Do you need redirects for the following files? \n - - ${{ steps.renamed-deleted-files .outputs.deleted_files }}"
50+ content : " ${{ steps.build-checklist-items.outputs.renamed_files }} ${{ steps.build-checklist-items .outputs.deleted_files }}"
3351 token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments