@@ -41,34 +41,51 @@ jobs:
41
41
id : date
42
42
run : echo "DT_STAMP"=$(date +'%Y-%m-%d %H:%M UTC') >> $GITHUB_ENV
43
43
44
- - name : Check for changes
45
- id : changes
44
+ - name : Check for changes in SPDX json files
45
+ id : src- changes
46
46
run : |
47
- has_changes =true
47
+ src_changed =true
48
48
# --quiet: Exits with 1 if there are changes; otherwise, exits with 0
49
- # exiting with anything other than 0 implies the command failed and the command following && will not execute leaving has_changes set to true
50
- # exiting with 0 implies the command was successful and the command following && will be executed setting has_changes to false
51
- git diff --quiet -- cmd/licenses.json cmd/exceptions.json && has_changes=false
52
- if [ $has_changes != 'true' ]; then
49
+ git diff --quiet -- cmd/licenses.json cmd/exceptions.json && src_changed=false
50
+ if [ $src_changed != 'true' ]; then
53
51
if [ ${{ github.event.inputs.force_run }} == 'true' ]; then
54
- echo -e '***************\nNo changes, but skipping abort due to force run\n***************'
52
+ echo -e '***************\nNo changes in spdx json , but skipping abort due to force run\n***************'
55
53
else
56
- echo -e '***************\nABORTING: No changes to license data\n***************'
54
+ echo -e '***************\nABORTING: No changes to spdx json data\n***************'
55
+ exit 0
57
56
fi
58
57
fi
59
- echo "HAS_CHANGES "=$has_changes >> $GITHUB_ENV
58
+ echo "src_changed "=$src_changed >> $GITHUB_ENV
60
59
61
60
- name : Run license extraction
62
- if : ${{ env.HAS_CHANGES == 'true' || github.event.inputs.force_run == 'true' }}
61
+ if : ${{ env.src_changed == 'true' || github.event.inputs.force_run == 'true' }}
63
62
run : |
64
63
cd cmd
65
64
echo "Current branch: $(git branch)"
66
65
go run . extract -l -e
67
66
cd ..
68
67
git log --oneline -n 5
69
68
69
+ - name : Check for changes in generated files
70
+ id : genfiles-changes
71
+ run : |
72
+ genfiles_changed=true
73
+ # --quiet: Exits with 1 if there are changes; otherwise, exits with 0
74
+ git diff --quiet -- spdxexp/spdxlicenses/*.go && genfiles_changed=false
75
+ if [ $genfiles_changed != 'true' ]; then
76
+ if [ ${{ github.event.inputs.force_run }} == 'true' ]; then
77
+ echo -e '***************\nNo changes to generated files, but skipping abort due to force run\n***************'
78
+ else
79
+ # This happens when the generated files are already up to date
80
+ # or the only changes in the source json are data not included in the generated files (e.g. IDs)
81
+ echo -e '***************\nABORTING: No changes to license data in generated files\n***************'
82
+ exit 0
83
+ fi
84
+ fi
85
+ echo "genfiles_changed"=$genfiles_changed >> $GITHUB_ENV
86
+
70
87
- name : Create Pull Request
71
- if : ${{ env.HAS_CHANGES == 'true' || github.event.inputs.force_run == 'true' }}
88
+ if : ${{ env.genfiles_changed == 'true' || github.event.inputs.force_run == 'true' }}
72
89
uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
73
90
with :
74
91
token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments