@@ -89,29 +89,38 @@ jobs:
89
89
uses : actions/github-script@v2
90
90
with :
91
91
script : |
92
+ const fs = require('fs');
92
93
const projectTags = require(`${process.env.GITHUB_WORKSPACE}/src/data/project-tags/project-tags.json`).map(t => t.slug);
93
94
94
95
const modifiedProjectFiles = process.env.PROJECT_FILES ? process.env.PROJECT_FILES.split(' ') : null
96
+ console.log(`Detected Project Files: ${JSON.stringify(modifiedProjectFiles, null, 2)}`)
95
97
let errors = []
96
98
97
99
// Check all modified project json files
98
100
if (modifiedProjectFiles) {
99
- modifiedProjectFiles.map(f => {
100
- const projectJson = require(`${process.env.GITHUB_WORKSPACE}/${f}`)
101
- console.log(projectJson)
102
-
103
- // Check tags
104
- let invalidTags = []
105
- if ( projectJson.projectTags ) {
106
- projectJson.projectTags.map(pt => {
107
- if (!projectTags.includes(pt)) {
108
- invalidTags.push(pt);
101
+ modifiedProjectFiles.forEach(f => {
102
+ const fileName = `${process.env.GITHUB_WORKSPACE}/${f}`;
103
+ const exists = fs.existsSync(fileName)
104
+
105
+ if (!exists) {
106
+ console.log(`INFO:: File not found: ${fileName}`)
107
+ } else {
108
+ const projectJson = require(`${process.env.GITHUB_WORKSPACE}/${f}`)
109
+ console.log(projectJson)
110
+
111
+ // Check tags
112
+ let invalidTags = []
113
+ if ( projectJson.projectTags ) {
114
+ projectJson.projectTags.map(pt => {
115
+ if (!projectTags.includes(pt)) {
116
+ invalidTags.push(pt);
117
+ }
118
+ })
119
+
120
+ // Collect invalidTags into errors
121
+ if (invalidTags.length > 0) {
122
+ errors.push({file: f, invalidTags: invalidTags})
109
123
}
110
- })
111
-
112
- // Collect invalidTags into errors
113
- if (invalidTags.length > 0) {
114
- errors.push({file: f, invalidTags: invalidTags})
115
124
}
116
125
}
117
126
})
0 commit comments