Skip to content

Commit

Permalink
v24.9.0 (#2)
Browse files Browse the repository at this point in the history
* fix: naming

* feat: update .todos

* feat: update .todos
  • Loading branch information
VladyslavKurmaz authored Sep 24, 2024
1 parent 1994d3f commit bbd9707
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .env.group.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TF_TOKEN_app_terraform_io=

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
25 changes: 17 additions & 8 deletions tln.conf.template → .tln.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const envs = {
const components = [
{ id: 'web/landing', proxy: false, ecr: 'web.landing', image: true, migrations: false },
// { id: 'backend/services/', proxy: false, ecr: 'backend.services.core', image: true, migrations: true },
]
];

const getComponents = (env, filter = (v) => !v.proxy, log = false ) => {
const ref = env.MYPROJECT_REPO_REF;
Expand Down Expand Up @@ -192,6 +192,8 @@ module.exports = {
env.TLN_UID = domains.prod.split('.').reverse().join('.');
env.TLN_VERSION = fs.readFileSync(path.join(__dirname, 'version'), 'utf8').trim();

env.MYPROJECT_SHA1 = exec("git log -1 --format='format:%h %s'").toString().trim().substring(0, 30);

env.MYPROJECT_CLOUD_PROVIDER = 'aws';
env.MYPROJECT_CLOUD_PROVIDER_ACCOUNT = account;
env.MYPROJECT_K8S_NAMESPACE = context.replace(':', '-');
Expand Down Expand Up @@ -235,17 +237,23 @@ module.exports = {
}).filter(item => !!item).join(',');

// Extract db, user, passsword from env vars and prepare input for Terraform
const connStrParcer = (conn) => {
if (conn) {
const dbu = conn.match(/\?user=(.*)\&/)[1];
const p = conn.match(/\&password=(.*)/)[1];
const p1 = dbu.split('-');
return { db: p1[0], user: p1[1], password: p };
}
}
const databases = [
//'MYPROJECT_PG_CONNECTION_STRING',
].map( v => {
const conn = env[v];
const dbu = conn.match(/\?user=(.*)\&/)[1];
const p = conn.match(/\&password=(.*)/)[1];
const p1 = dbu.split('-');
//console.log(dbu, p, p1[0], p1[1]);
return `"${p1[0]}" = { owner = "${p1[1]}", password = "${p}" }`;
if (conn) {
const {db, user, password} = connStrParcer(conn);
return `"${db}" = { owner = "${user}", password = "${password}" }`;
}
}).join(', ');

env.TF_VAR_databases = `{ ${databases} }`;
//console.log(env.TF_VAR_databases);
//env.TF_VAR_databases = `{ "user" = { owner = "admin", password = "admin" }, "balance" = { owner = "admin", password = "admin" } }`;
Expand All @@ -266,7 +274,7 @@ module.exports = {
];
},
inherits: async (tln) => [],
depends: async (tln) => [],
depends: async (tln) => ['aws-cli-2.17.9'],
steps: async (tln) =>
[
['init', 'init:link', '', ''],
Expand Down Expand Up @@ -303,6 +311,7 @@ module.exports = {
//`tln install ${['platform', 'env', script.env.MYPROJECT_CLOUD_PROVIDER].join('/')} --depends`,
//`tln install ${['platform', 'app'].join('/')} --depends`,
//`tln install ${['platform', 'tenant'].join('/')} --depends`,
//`tln exec -c 'aws --version'`,
//`tln exec platform/env/aws -c 'aws ecr get-login-password | docker login --username AWS --password-stdin ${script.env.TLN_DOCKER_REGISTRY}'`
]));
}
Expand Down
18 changes: 18 additions & 0 deletions .todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* TPM

team:
vlad.k:
email: [email protected]

timeline:
v24.9.0:
date: 2024-09-24
v24.10.0:
date: 2024-10-xx

tasks: |-
[-:003:v24.10.0] @vlad.k Create repository to test CI/CD skeleton
[-:002:v24.10.0] @vlad.k Split prereq & login command
[+:001:v24.9.0] @vlad.k Set default env in base.yml - '', dispatch/push - dev01

*/
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# tln-cicd-github
# tln-cicd-github
CI/CD skeleton

## Integration
* Add this repository using git subtree (execute from the root of the repository and add into main branch using merge commit)
```
tln subtree-add -- --prefix .github/workflows --subtree https://github.com/project-talan/tln-cicd-github.git --ref v24.9.0 --squash
```
* Install Nodejs libraries (execute next command from the root of the repository)
```
npm i js-yaml assign-deep fast-glob --save
```
* Copy .github/workflows/.tln.conf.template to the repository root and update it with actuail values: project name, terraform cloud parameters, AWS account etc.
```
cp .github/workflows/.tln.conf.template .tln.conf
```
8 changes: 4 additions & 4 deletions base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
environment:
type: string
description: Environment
default: "ci"
default: ""
tests:
type: string
description: Tests
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
with:
node-version: "22.6.0"

- run: npm i -g [email protected]
- run: npm i -g [email protected] [email protected]

- uses: actions/checkout@v4
with:
Expand All @@ -84,7 +84,7 @@ jobs:
large-packages: true
docker-images: false
swap-storage: true

- name: Configure environment
env:
ENVIRONMENT_GROUP: ${{ secrets.ENVIRONMENT_GROUP }}
Expand All @@ -96,7 +96,7 @@ jobs:
mkdir secrets
echo "$ENVIRONMENT_GROUP" > secrets/.env.${{ inputs.group }}
tln configure-ci:prereq:get-secrets
tln configure-ci:get-secrets:prereq
ls -la secrets
- name: Init
Expand Down
2 changes: 1 addition & 1 deletion dispatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
environment:
type: string
description: Environment
default: ci
default: dev01
tests:
type: string
description: Tests unit, spec, static, blind, api, ui, load
Expand Down

0 comments on commit bbd9707

Please sign in to comment.