36
36
RENAMED_FILES : ${{ steps.changed-files.outputs.all_old_new_renamed_files }}
37
37
run : |
38
38
renamed_redirects=""
39
+
39
40
for file in $RENAMED_FILES; do
40
41
41
42
# only run for .txt files
@@ -56,11 +57,13 @@ jobs:
56
57
57
58
# if redirect not already in file, add to string to add to PR description
58
59
if ! grep -qx "$redirect" $REDIRECTS_FILE; then
59
- renamed_redirects+="<li>[<v>-*]: $redirect</li>"
60
- echo "${renamed_redirects}"
60
+ renamed_redirects+="$redirect,"
61
61
fi
62
62
done
63
63
64
+ # cut trailing comma
65
+ renamed_redirects="${renamed_redirects%,}"
66
+
64
67
echo "redirects=${renamed_redirects}" >> "$GITHUB_OUTPUT"
65
68
66
69
- name : Find Missing Redirects for Deleted Files
70
73
DELETED_FILES : ${{ steps.changed-files.outputs.deleted_files }}
71
74
run : |
72
75
deleted_redirects=""
76
+
73
77
for file in $DELETED_FILES; do
74
78
75
79
# only run for .txt files
@@ -87,10 +91,12 @@ jobs:
87
91
88
92
# if redirect not already in file, add to string to add to PR description
89
93
if ! grep -qx "$redirect" $REDIRECTS_FILE; then
90
- deleted_redirects+="<li>[<v>-*]: $redirect</li>"
91
- echo "${deleted_redirects}"
94
+ deleted_redirects+="$redirect,"
92
95
fi
93
96
done
97
+
98
+ # cut trailing comma
99
+ deleted_redirects="${deleted_redirects%,}"
94
100
95
101
echo "redirects=${deleted_redirects}" >> "$GITHUB_OUTPUT"
96
102
@@ -100,17 +106,30 @@ jobs:
100
106
RENAMED_REDIRECTS : ${{ steps.renamed-files.outputs.redirects }}
101
107
DELETED_REDIRECTS : ${{ steps.deleted-files.outputs.redirects }}
102
108
run : |
103
- combined_redirect_html="${RENAMED_REDIRECTS}${DELETED_REDIRECTS}"
109
+ # empty string that stays empty if there are no redirects to suggest
110
+ redirect_html=""
104
111
105
- echo "redirect_html=${combined_redirect_html}" >> "$GITHUB_OUTPUT"
112
+ combined_redirect_string="${RENAMED_REDIRECTS},${DELETED_REDIRECTS}"
113
+
114
+ IFS=','
115
+ for redirect in $combined_redirect_string; do
116
+ if [[ ! -z "$redirect" ]]; then
117
+ if [[ -z "$redirect_html" ]]; then
118
+ redirect_html="<i>Suggested redirects for moved/deleted files (replace <v> with earliest backport target version):</i>"
119
+ fi
120
+ redirect_html+="<li>[<v>-\*]: $redirect</li>"
121
+ fi
122
+ done
123
+
124
+ echo "redirect_html=${redirect_html}" >> "$GITHUB_OUTPUT"
106
125
107
126
- name : Update PR Description
108
127
uses : MongoCaleb/pr-description-action@4bdfe35b98f64532b419ad20b350a92546cd3aa1
109
128
with :
110
129
regex : " - \\ [ \\ ] Did you add redirects\\ ?.*"
111
130
appendContentOnMatchOnly : false
112
131
regexFlags : is
113
- content : " - [ ] Did you add redirects?\n ${{ steps.renamed-files.outputs.redirects }}${{ steps.deleted-files .outputs.redirects }}"
132
+ content : " - [ ] Did you add redirects?\n ${{ steps.build-redirect-html .outputs.redirect_html }}"
114
133
token : ${{ secrets.GITHUB_TOKEN }}
115
134
116
135
- name : Check for duplicates in redirects file
@@ -123,5 +142,5 @@ jobs:
123
142
exit 1 # error
124
143
fi
125
144
else
126
- echo "Redirects file doesn't exist. Skipping duplicate check."
145
+ "Redirects file doesn't exist. Skipping duplicate check."
127
146
fi
0 commit comments