Skip to content

Commit d596be7

Browse files
committed
fix(release-actions): match paths with changed files
Signed-off-by: Emilien Escalle <[email protected]>
1 parent 36ff8cb commit d596be7

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

.github/workflows/__main-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
sync-docs:
4444
needs: release
45-
if: github.event_name != 'schedule' && github.ref_name != github.event.repository.default_branch && needs.release.outputs.artifact-id
45+
if: github.event_name != 'schedule' && github.ref_name == github.event.repository.default_branch && needs.release.outputs.artifact-id
4646
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@c40c17f7d6a8090950b3ef4bfc70502707a6bb9f # 0.3.0
4747
permissions:
4848
contents: read

.github/workflows/release-actions.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
6767
with:
6868
script: |
69+
const path = require('node:path');
6970
const manifestFiles = [];
7071
7172
// Retrieve action manifests
@@ -96,6 +97,7 @@ jobs:
9697
core.setOutput(
9798
'paths',
9899
manifestFiles
100+
.map(manifestPath => path.relative(process.env.GITHUB_WORKSPACE, manifestPath))
99101
.join('\n')
100102
);
101103
@@ -141,6 +143,7 @@ jobs:
141143
core.setOutput(
142144
'paths',
143145
allFiles
146+
.map(filePath => path.relative(process.env.GITHUB_WORKSPACE, filePath))
144147
.join('\n')
145148
);
146149
@@ -152,7 +155,6 @@ jobs:
152155
${{ steps.get-documentation-files.outputs.paths }}
153156
${{ steps.get-manifest-files.outputs.paths }}
154157
dir_names_exclude_current_dir: true
155-
json: true
156158

157159
- id: get-changed-files
158160
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -164,40 +166,50 @@ jobs:
164166
with:
165167
script: |
166168
const { join, relative } = require('path');
167-
const changedFilesOutputs = process.env.CHANGED_FILES;
168-
const changedFiles = JSON.parse(changedFilesOutputs).map(f => f.trim()).filter(Boolean).map(f => join(process.env.GITHUB_WORKSPACE, f));
169+
const changedFiles = process.env.CHANGED_FILES
170+
.split('\n')
171+
.map(f => f.trim())
172+
.filter(Boolean);
169173
174+
core.debug(`Changed files: ${changedFiles.join(', ')}`);
170175
const currentWorkflow = process.env.GITHUB_WORKFLOW_REF.replace(`${process.env.GITHUB_REPOSITORY}/`, '').replace(/@.*/, '');
171176
const currentWorkflowHasChanged = changedFiles.includes(currentWorkflow);
177+
core.debug(`Current workflow: ${currentWorkflow} - has changed: ${currentWorkflowHasChanged}`);
172178
173179
const updateAll = process.env.UPDATE_ALL.toLowerCase() === 'true';
174180
const forceUpdate = currentWorkflowHasChanged || updateAll;
181+
core.debug(`Force update: ${forceUpdate}`);
175182
176183
const documentationFiles = process.env.DOCUMENTATION_FILES
177184
.split('\n')
178-
.map(f => f.trim())
185+
.map(file => file.trim())
179186
.filter(Boolean);
180187
188+
core.debug(`Documentation files: ${documentationFiles.join(', ')}`);
189+
181190
const changedDocumentationFiles = new Set();
182-
for(const docPath of documentationFiles) {
191+
for (const docPath of documentationFiles) {
183192
if (forceUpdate || changedFiles.includes(docPath)) {
184193
core.debug(`Including documentation file: ${docPath}`);
185194
changedDocumentationFiles.add(docPath);
186195
}
187196
}
188197
198+
core.debug(`Changed documentation files: ${Array.from(changedDocumentationFiles).join(', ')}`);
199+
189200
core.setOutput(
190201
'documentation-files',
191202
Array.from(changedDocumentationFiles)
192-
.map(filePath => relative(process.env.GITHUB_WORKSPACE, filePath))
193203
.join('\n')
194204
);
195205
196206
const manifestFiles = process.env.MANIFEST_FILES
197207
.split('\n')
198-
.map(f => f.trim())
208+
.map(file => file.trim())
199209
.filter(Boolean);
200210
211+
core.debug(`Manifest files: ${manifestFiles.join(', ')}`);
212+
201213
const changedManifestFiles = new Set();
202214
for(const manifestPath of manifestFiles) {
203215
if (forceUpdate || changedFiles.includes(manifestPath)) {
@@ -206,10 +218,11 @@ jobs:
206218
}
207219
}
208220
221+
core.debug(`Changed manifest files: ${Array.from(changedManifestFiles).join(', ')}`);
222+
209223
core.setOutput(
210224
'manifest-files',
211225
Array.from(changedManifestFiles)
212-
.map(filePath => relative(process.env.GITHUB_WORKSPACE, filePath))
213226
.join('\n')
214227
);
215228

0 commit comments

Comments
 (0)