Skip to content

Commit

Permalink
fix: use propagateTags service value
Browse files Browse the repository at this point in the history
  • Loading branch information
guikcd committed Jan 21, 2025
1 parent 78da1be commit fe3852f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ inputs:
description: "Determines whether to turn on Amazon ECS managed tags 'aws:ecs:serviceName' and 'aws:ecs:clusterName' for the tasks in the service."
required: false
propagate-tags:
description: "Determines to propagate the tags from the 'SERVICE' to the task. Will default to 'NONE'."
description: "Determines to propagate the tags from the 'SERVICE' to the task. Will default to service propagateTags value ('NONE' if not set at service creation)."
required: false
outputs:
task-definition-arn:
Expand Down
19 changes: 18 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,24 @@ async function run() {
if (enableECSManagedTagsInput !== '') {
enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
}
const propagateTags = core.getInput('propagate-tags', { required: false }) || 'NONE';

// get the current propagateTags of the service
// set it to NONE if api answer null (old services?)
let currentPropagateTags = 'NONE';
try {
describeServicesResponse = await ecs.describeServices({
services: [service],
cluster: cluster
})
if (describeServicesResponse.services[0].propagateTags != null) {
currentPropagateTags = describeServicesResponse.services[0].propagateTags;
}
} catch (error) {
core.setFailed("Failed to get current 'propagateTags' of the service: " + error.message);
throw(error);
}
core.debug(`Current service 'propagateTags' value: ${currentPropagateTags}`);
const propagateTags = core.getInput('propagate-tags', { required: false }) || currentPropagateTags;

// Register the task definition
core.debug('Registering the task definition');
Expand Down

0 comments on commit fe3852f

Please sign in to comment.