Skip to content

Commit 76bdeb4

Browse files
authored
fix: update action output handling for closed events to ensure accurate module release information (#273)
1 parent 6d809c3 commit 76bdeb4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ The following outputs are available from this action:
395395
}
396396
```
397397

398+
> **Note**: When using outputs during the `closed` event, the `changed-modules-map` output will show `latestTag` as the
399+
> previous release version, while `releaseTag` and `releaseType` reflect the new release that was just created. To
400+
> reference the newly published version, use the value of `releaseTag`.
401+
398402
## Inspiration
399403

400404
This action was inspired by the blog post

src/main.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,17 @@ export async function run(): Promise<void> {
210210
const releasesToDelete = TerraformModule.getReleasesToDelete(allReleases, terraformModules);
211211
const tagsToDelete = TerraformModule.getTagsToDelete(allTags, terraformModules);
212212

213+
// Important: Let's set the action outputs prior to performing the closed/merge request release.
214+
// This is because the changed modules filters on [module.needsRelease()] which will be false
215+
// after the release is created. By setting the outputs here, we ensure they accurately reflect
216+
// the modules that were changed and needed release at this point in time.
217+
setActionOutputs(terraformModules);
218+
213219
if (context.isPrMergeEvent) {
214220
await handlePullRequestMergedEvent(config, terraformModules, releasesToDelete, tagsToDelete);
215221
} else {
216222
await handlePullRequestEvent(terraformModules, releasesToDelete, tagsToDelete);
217223
}
218-
219-
setActionOutputs(terraformModules);
220224
} catch (error) {
221225
if (error instanceof Error) {
222226
setFailed(error.message);

0 commit comments

Comments
 (0)