Skip to content

fix: when no input enableECSManagedTagsInput, not include it to request params #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ async function run() {
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false';
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
const desiredCount = parseInt((core.getInput('desired-count', {required: false})));
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || 'false';
const enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || '';
let enableECSManagedTags = null;
if (enableECSManagedTagsInput !== '') {
enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
}
const propagateTags = core.getInput('propagate-tags', { required: false }) || 'NONE';

// Register the task definition
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,11 @@ async function run() {
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false';
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
const desiredCount = parseInt((core.getInput('desired-count', {required: false})));
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || 'false';
const enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || '';
let enableECSManagedTags = null;
if (enableECSManagedTagsInput !== '') {
enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
}
const propagateTags = core.getInput('propagate-tags', { required: false }) || 'NONE';

// Register the task definition
Expand Down
144 changes: 132 additions & 12 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -954,7 +954,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
Expand Down Expand Up @@ -995,7 +995,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
Expand Down Expand Up @@ -1036,7 +1036,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
Expand Down Expand Up @@ -1079,7 +1079,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: true,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
});
Expand All @@ -1105,7 +1105,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE'
});
});
Expand Down Expand Up @@ -1152,7 +1152,7 @@ describe('Deploy to ECS', () => {
taskDefinition: 'task:def:arn',
overrides: {"containerOverrides": []},
networkConfiguration: null,
enableECSManagedTags: false,
enableECSManagedTags: null,
tags: []
});

Expand Down Expand Up @@ -1276,7 +1276,7 @@ describe('Deploy to ECS', () => {
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
enableECSManagedTags: null,
propagateTags: 'NONE',
});
expect(mockRunTask).toHaveBeenCalledWith({
Expand All @@ -1287,7 +1287,7 @@ describe('Deploy to ECS', () => {
launchType: 'EC2',
overrides: { containerOverrides: [{ name: 'someapp', command: 'somecmd' }] },
networkConfiguration: { awsvpcConfiguration: { subnets: ['a', 'b'], securityGroups: ['c', 'd'], assignPublicIp: "DISABLED" } },
enableECSManagedTags: false,
enableECSManagedTags: null,
tags: []
});
expect(core.setOutput).toHaveBeenNthCalledWith(2, 'run-task-arn', ["arn:aws:ecs:fake-region:account_id:task/arn"]);
Expand Down Expand Up @@ -1348,6 +1348,62 @@ describe('Deploy to ECS', () => {
launchType: 'EC2',
overrides: { containerOverrides: [] },
networkConfiguration: null,
enableECSManagedTags: null,
tags: []
});
});

test('run task with setting true to enableECSManagedTags', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('task-definition.json') // task-definition
.mockReturnValueOnce('') // service
.mockReturnValueOnce('somecluster') // cluster
.mockReturnValueOnce('') // wait-for-service-stability
.mockReturnValueOnce('') // wait-for-minutes
.mockReturnValueOnce('') // force-new-deployment
.mockReturnValueOnce('') // desired-count
.mockReturnValueOnce('true') // enable-ecs-managed-tags
.mockReturnValueOnce('') // propagate-tags
.mockReturnValueOnce('true'); // run-task

await run();
expect(mockRunTask).toHaveBeenCalledWith({
startedBy: 'GitHub-Actions',
cluster: 'somecluster',
taskDefinition: 'task:def:arn',
capacityProviderStrategy: null,
launchType: 'FARGATE',
overrides: { containerOverrides: [] },
networkConfiguration: null,
enableECSManagedTags: true,
tags: []
});
});

test('run task with setting false to enableECSManagedTags', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('task-definition.json') // task-definition
.mockReturnValueOnce('') // service
.mockReturnValueOnce('somecluster') // cluster
.mockReturnValueOnce('') // wait-for-service-stability
.mockReturnValueOnce('') // wait-for-minutes
.mockReturnValueOnce('') // force-new-deployment
.mockReturnValueOnce('') // desired-count
.mockReturnValueOnce('false') // enable-ecs-managed-tags
.mockReturnValueOnce('') // propagate-tags
.mockReturnValueOnce('true'); // run-task

await run();
expect(mockRunTask).toHaveBeenCalledWith({
startedBy: 'GitHub-Actions',
cluster: 'somecluster',
taskDefinition: 'task:def:arn',
capacityProviderStrategy: null,
launchType: 'FARGATE',
overrides: { containerOverrides: [] },
networkConfiguration: null,
enableECSManagedTags: false,
tags: []
});
Expand Down Expand Up @@ -1519,7 +1575,39 @@ describe('Deploy to ECS', () => {
expect(core.setFailed).toHaveBeenNthCalledWith(2, 'Could not parse');
});

test('propagate service tags from service and enable ecs managed tags', async () => {
test('propagate service tags from service', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('task-definition.json') // task-definition
.mockReturnValueOnce('service-456') // service
.mockReturnValueOnce('cluster-789') // cluster
.mockReturnValueOnce('false') // wait-for-service-stability
.mockReturnValueOnce('') // wait-for-minutes
.mockReturnValueOnce('') // force-new-deployment
.mockReturnValueOnce('') // desired-count
.mockReturnValueOnce('') // enable-ecs-managed-tags
.mockReturnValueOnce('SERVICE'); // propagate-tags

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
services: ['service-456']
});
expect(mockEcsUpdateService).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: null,
propagateTags: 'SERVICE'
});
});

test('update service with setting true to enableECSManagedTags', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('task-definition.json') // task-definition
Expand Down Expand Up @@ -1550,4 +1638,36 @@ describe('Deploy to ECS', () => {
propagateTags: 'SERVICE'
});
});
});

test('update service with setting false to enableECSManagedTags', async () => {
core.getInput = jest
.fn()
.mockReturnValueOnce('task-definition.json') // task-definition
.mockReturnValueOnce('service-456') // service
.mockReturnValueOnce('cluster-789') // cluster
.mockReturnValueOnce('false') // wait-for-service-stability
.mockReturnValueOnce('') // wait-for-minutes
.mockReturnValueOnce('') // force-new-deployment
.mockReturnValueOnce('') // desired-count
.mockReturnValueOnce('false') // enable-ecs-managed-tags
.mockReturnValueOnce('SERVICE'); // propagate-tags

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
services: ['service-456']
});
expect(mockEcsUpdateService).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: false,
enableECSManagedTags: false,
propagateTags: 'SERVICE'
});
});
});
Loading