@@ -123,14 +123,19 @@ jobs:
123
123
- name : Get changed files
124
124
id : changed-files
125
125
uses : tj-actions/changed-files@v40
126
+ with :
127
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
126
128
127
129
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
128
130
# with:
129
131
# since_last_remote_commit: true
130
132
131
133
- name : List all changed files
134
+ env :
135
+ ALL_CHANGED_FILES : |-
136
+ ${{ steps.changed-files.outputs.all_changed_files }}
132
137
run : |
133
- for file in ${{ steps.changed-files.outputs.all_changed_files }} ; do
138
+ for file in "$ALL_CHANGED_FILES" ; do
134
139
echo "$file was changed"
135
140
done
136
141
@@ -139,14 +144,18 @@ jobs:
139
144
id : changed-markdown-files
140
145
uses : tj-actions/changed-files@v40
141
146
with :
147
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
142
148
# Avoid using single or double quotes for multiline patterns
143
149
files : |
144
150
**.md
145
151
146
152
- name : List all changed files markdown files
147
153
if : steps.changed-markdown-files.outputs.any_changed == 'true'
154
+ env :
155
+ ALL_CHANGED_FILES : |-
156
+ ${{ steps.changed-markdown-files.outputs.all_changed_files }}
148
157
run : |
149
- for file in ${{ steps.changed-markdown-files.outputs.all_changed_files }} ; do
158
+ for file in "$ALL_CHANGED_FILES" ; do
150
159
echo "$file was changed"
151
160
done
152
161
@@ -155,6 +164,7 @@ jobs:
155
164
id : changed-files-yaml
156
165
uses : tj-actions/changed-files@v40
157
166
with :
167
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
158
168
files_yaml : |
159
169
doc:
160
170
- '**.md'
@@ -170,29 +180,39 @@ jobs:
170
180
- name : Run step if test file(s) change
171
181
# NOTE: Ensure all outputs are prefixed by the same key used above e.g. `test_(...)` | `doc_(...)` | `src_(...)` when trying to access the `any_changed` output.
172
182
if : steps.changed-files-yaml.outputs.test_any_changed == 'true'
183
+ env :
184
+ TEST_ALL_CHANGED_FILES : |-
185
+ ${{ steps.changed-files-yaml.outputs.test_all_changed_files }}
173
186
run : |
174
187
echo "One or more test file(s) has changed."
175
- echo "List all the files that have changed: ${{ steps.changed-files-yaml.outputs.test_all_changed_files }} "
188
+ echo "List all the files that have changed: $TEST_ALL_CHANGED_FILES "
176
189
177
190
- name : Run step if doc file(s) change
178
191
if : steps.changed-files-yaml.outputs.doc_any_changed == 'true'
192
+ env :
193
+ DOC_ALL_CHANGED_FILES : |-
194
+ ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }}
179
195
run : |
180
196
echo "One or more doc file(s) has changed."
181
- echo "List all the files that have changed: ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }} "
197
+ echo "List all the files that have changed: $DOC_ALL_CHANGED_FILES "
182
198
183
199
# Example 3
184
200
- name : Get changed files in the docs folder
185
201
id : changed-files-specific
186
202
uses : tj-actions/changed-files@v40
187
203
with :
204
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
188
205
files : docs/*.{js,html} # Alternatively using: `docs/**`
189
206
files_ignore : docs/static.js
190
207
191
208
- name : Run step if any file(s) in the docs folder change
192
209
if : steps.changed-files-specific.outputs.any_changed == 'true'
210
+ env :
211
+ ALL_CHANGED_FILES : |-
212
+ ${{ steps.changed-files-specific.outputs.all_changed_files }}
193
213
run : |
194
214
echo "One or more files in the docs folder has changed."
195
- echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }} "
215
+ echo "List all the files that have changed: $ALL_CHANGED_FILES "
196
216
` ` `
197
217
198
218
#### Using Github's API :octocat:
@@ -224,10 +244,15 @@ jobs:
224
244
- name : Get changed files
225
245
id : changed-files
226
246
uses : tj-actions/changed-files@v40
247
+ with :
248
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
227
249
228
250
- name : List all changed files
251
+ env :
252
+ ALL_CHANGED_FILES : |-
253
+ ${{ steps.changed-files.outputs.all_changed_files }}
229
254
run : |
230
- for file in ${{ steps.changed-files.outputs.all_changed_files }} ; do
255
+ for file in "$ALL_CHANGED_FILES" ; do
231
256
echo "$file was changed"
232
257
done
233
258
` ` `
@@ -265,12 +290,17 @@ jobs:
265
290
- name : Get changed files
266
291
id : changed-files
267
292
uses : tj-actions/changed-files@v40
293
+ with :
294
+ safe_output : false # true by default, set to false because we are using an environment variable to store the output and avoid command injection.
268
295
269
296
# NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit.
270
297
271
298
- name : List all changed files
299
+ env :
300
+ ALL_CHANGED_FILES : |-
301
+ ${{ steps.changed-files.outputs.all_changed_files }}
272
302
run : |
273
- for file in ${{ steps.changed-files.outputs.all_changed_files }} ; do
303
+ for file in "$ALL_CHANGED_FILES" ; do
274
304
echo "$file was changed"
275
305
done
276
306
...
@@ -715,10 +745,15 @@ See [inputs](#inputs) for more information.
715
745
- name : Get changed files
716
746
id : changed-files
717
747
uses : tj-actions/changed-files@v40
748
+ with :
749
+ safe_output : false
718
750
719
751
- name : List all added files
752
+ env :
753
+ ADDED_FILES : |-
754
+ ${{ steps.changed-files.outputs.added_files }}
720
755
run : |
721
- for file in ${{ steps.changed-files.outputs.added_files }} ; do
756
+ for file in "$ADDED_FILES" ; do
722
757
echo "$file was added"
723
758
done
724
759
...
@@ -736,6 +771,8 @@ See [outputs](#outputs) for a list of all available outputs.
736
771
- name : Get changed files
737
772
id : changed-files
738
773
uses : tj-actions/changed-files@v40
774
+ with :
775
+ safe_output : false
739
776
740
777
- name : Run a step if my-file.txt was modified
741
778
if : contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
@@ -756,8 +793,9 @@ See [outputs](#outputs) for a list of all available outputs.
756
793
757
794
- name : Get changed files and write the outputs to a Txt file
758
795
id : changed-files-write-output-files-txt
759
- uses : ./
796
+ uses : tj-actions/changed-files@v40
760
797
with :
798
+ safe_output : false
761
799
write_output_files : true
762
800
763
801
- name : Verify the contents of the .github/outputs/added_files.txt file
@@ -775,8 +813,9 @@ See [outputs](#outputs) for a list of all available outputs.
775
813
...
776
814
- name : Get changed files and write the outputs to a JSON file
777
815
id : changed-files-write-output-files-json
778
- uses : ./
816
+ uses : tj-actions/changed-files@v40
779
817
with :
818
+ safe_output : false
780
819
json : true
781
820
write_output_files : true
782
821
@@ -820,6 +859,7 @@ See [inputs](#inputs) for more information.
820
859
id : changed-files-specific
821
860
uses : tj-actions/changed-files@v40
822
861
with :
862
+ safe_output : false
823
863
files : |
824
864
my-file.txt
825
865
*.sh
@@ -840,15 +880,21 @@ See [inputs](#inputs) for more information.
840
880
841
881
- name : Run step if any of the listed files above is deleted
842
882
if : steps.changed-files-specific.outputs.any_deleted == 'true'
883
+ env :
884
+ DELETED_FILES : |-
885
+ ${{ steps.changed-files-specific.outputs.deleted_files }}
843
886
run : |
844
- for file in ${{ steps.changed-files-specific.outputs.deleted_files }} ; do
887
+ for file in "$DELETED_FILES" ; do
845
888
echo "$file was deleted"
846
889
done
847
890
848
891
- name : Run step if all listed files above have been deleted
849
892
if : steps.changed-files-specific.outputs.only_deleted == 'true'
893
+ env :
894
+ DELETED_FILES : |-
895
+ ${{ steps.changed-files-specific.outputs.deleted_files }}
850
896
run : |
851
- for file in ${{ steps.changed-files-specific.outputs.deleted_files }} ; do
897
+ for file in "$DELETED_FILES" ; do
852
898
echo "$file was deleted"
853
899
done
854
900
...
@@ -958,14 +1004,18 @@ jobs:
958
1004
id : changed-files-specific
959
1005
uses : tj-actions/changed-files@v40
960
1006
with :
1007
+ safe_output : false
961
1008
base_sha : ${{ steps.get-base-sha.outputs.base_sha }}
962
1009
files : .github/**
963
1010
964
1011
- name : Run step if any file(s) in the .github folder change
965
1012
if : steps.changed-files-specific.outputs.any_changed == 'true'
1013
+ env :
1014
+ ALL_CHANGED_FILES : |-
1015
+ ${{ steps.changed-files-specific.outputs.all_changed_files }}
966
1016
run : |
967
1017
echo "One or more files in the .github folder has changed."
968
- echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }} "
1018
+ echo "List all the files that have changed: $ALL_CHANGED_FILES "
969
1019
...
970
1020
```
971
1021
@@ -988,11 +1038,15 @@ See [inputs](#inputs) for more information.
988
1038
id : changed-files-for-dir1
989
1039
uses : tj-actions/changed-files@v40
990
1040
with :
1041
+ safe_output : false
991
1042
path : dir1
992
1043
993
1044
- name : List all added files in dir1
1045
+ env :
1046
+ ADDED_FILES : |-
1047
+ ${{ steps.changed-files-for-dir1.outputs.added_files }}
994
1048
run : |
995
- for file in ${{ steps.changed-files-for-dir1.outputs.added_files }} ; do
1049
+ for file in "$ADDED_FILES" ; do
996
1050
echo "$file was added"
997
1051
done
998
1052
...
@@ -1015,7 +1069,7 @@ See [inputs](#inputs) for more information.
1015
1069
1016
1070
- name : Run changed-files with quotepath disabled for a specified list of file(s)
1017
1071
id : changed-files-quotepath-specific
1018
- uses : ./
1072
+ uses : tj-actions/changed-files@v40
1019
1073
with :
1020
1074
files : test/test-è.txt
1021
1075
quotepath : " false"
0 commit comments