Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
feat: add task environment
Browse files Browse the repository at this point in the history
  • Loading branch information
arantespp committed May 13, 2021
1 parent 3ad296a commit 4711e0c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cicd/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ssh-key*
ssh-key*
npmtoken
10 changes: 10 additions & 0 deletions cicd/carlin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as fs from 'fs';

export default {
pipelines: ['tag'],
sshKey: './ssh-key',
sshUrl: '[email protected]:ttoss/carlin.git',
taskEnvironment: [
{ Name: 'NPM_TOKEN', Value: fs.readFileSync('./npmtoken', 'utf-8') },
],
};
4 changes: 0 additions & 4 deletions cicd/carlin.yml

This file was deleted.

1 change: 1 addition & 0 deletions packages/cli/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
6 changes: 5 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
"scripts": {
"test": "jest",
"build": "tsc",
"prepare": "npm run test && rm -rf dist && npm run build"
"prepare": "npm run test && npm run build",
"deploy": "npm publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ttoss/carlin.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"keywords": [],
"author": {
"email": "[email protected]",
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/deploy/cicd/cicd.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const getCicdTemplate = ({
cpu = ECS_TASK_DEFAULT_CPU,
memory = ECS_TASK_DEFAULT_MEMORY,
s3,
taskEnvironment = [],
}: {
pipelines: Pipeline[];
cpu?: string;
Expand All @@ -81,6 +82,7 @@ export const getCicdTemplate = ({
key: string;
versionId: string;
};
taskEnvironment?: Array<{ Name: string; Value: string }>;
}): CloudFormationTemplate => {
const resources: CloudFormationTemplate['Resources'] = {};

Expand Down Expand Up @@ -633,6 +635,7 @@ export const getCicdTemplate = ({
ContainerDefinitions: [
{
Environment: [
...taskEnvironment,
{
/**
* https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-metadata.html#enable-metadata
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/deploy/cicd/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ export const options = {
demandOption: true,
type: 'string',
},
/**
* This option has the format:
*
* ```ts
* Array<{
* Name: string,
* Value: string,
* }>
* ```
*/
'task-environment': {
alias: ['te'],
default: [],
describe:
'A list of environment variables that will be passed to the ECS container task.',
type: 'array',
},
} as const;

export const deployCicdCommand: CommandModule<
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/deploy/cicd/deployCicd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ export const deployCicd = async ({
repositoryUpdate,
sshKey,
sshUrl,
taskEnvironment,
}: {
cpu?: string;
memory?: string;
pipelines: Pipeline[];
repositoryUpdate?: boolean;
sshKey: string;
sshUrl: string;
taskEnvironment: Array<{ Name: string; Value: string }>;
}) => {
try {
const { stackName } = await handleDeployInitialization({
Expand All @@ -109,6 +111,7 @@ export const deployCicd = async ({
memory,
pipelines,
s3: await deployCicdLambdas({ stackName }),
taskEnvironment,
}),
params: {
StackName: stackName,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"incremental": false, // Do not create tsconfig.tsbuildinfo
"outDir": "dist",
"noEmit": false
"noEmit": false,
"declaration": false
},
"include": ["src"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
Expand Down
6 changes: 0 additions & 6 deletions packages/website/carlin.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
environments:
Staging:
aliases:
- carlin.ttoss.dev
csp:
default-src: ["* 'unsafe-inline' 'unsafe-eval'", replace]
stackName: CarlinWebsite
Production:
aliases:
- carlin.ttoss.dev
Expand Down

0 comments on commit 4711e0c

Please sign in to comment.