mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-29 00:30:06 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7781298e6e | ||
|
|
2c00d3249a | ||
|
|
cd7c7d538f | ||
|
|
a07247d538 | ||
|
|
153ba1a98b | ||
|
|
46519323f8 | ||
|
|
a51d52d68e | ||
|
|
555ff2eda9 | ||
|
|
5d1a54a720 | ||
|
|
8399a0e4c1 | ||
|
|
cf54cb0bc2 | ||
|
|
e52af6844b | ||
|
|
2344e4dba3 |
@@ -2,37 +2,49 @@ name: Deploy
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- alpha
|
|
||||||
- beta
|
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
environment:
|
||||||
|
description: 'Deployment environment'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- dev
|
||||||
|
- stg
|
||||||
|
- prd
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
extract_environment:
|
extract_environment:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
environment: ${{ steps.extract_environment.outputs.environment }}
|
environment: ${{ steps.extract_environment.outputs.environment }}
|
||||||
|
env:
|
||||||
|
EVENT: ${{ github.event_name }}
|
||||||
|
DEPLOY_ENV: ${{ github.event.inputs.environment }}
|
||||||
steps:
|
steps:
|
||||||
- name: Extract Environment
|
- name: Extract Environment
|
||||||
run: |
|
run: |
|
||||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
if [ ${EVENT} == "workflow_dispatch" ]; then
|
||||||
|
echo "##[set-output name=environment;]$(echo ${DEPLOY_ENV})"
|
||||||
|
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||||
echo "##[set-output name=environment;]$(echo "prd")"
|
echo "##[set-output name=environment;]$(echo "prd")"
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
|
||||||
echo "##[set-output name=environment;]$(echo "dev")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
|
||||||
echo "##[set-output name=environment;]$(echo "stg")"
|
|
||||||
fi
|
fi
|
||||||
id: extract_environment
|
id: extract_environment
|
||||||
|
|
||||||
semantic_release:
|
semantic_release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
|
#new_release_published: ${{ steps.semantic.outputs.last_release_version != steps.semantic.outputs.new_release_version }}
|
||||||
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
||||||
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
#new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
||||||
|
new_release_version: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Semantic Release
|
- if: github.event_name != 'workflow_dispatch'
|
||||||
|
name: Semantic Release
|
||||||
uses: cycjimmy/semantic-release-action@v2
|
uses: cycjimmy/semantic-release-action@v2
|
||||||
id: semantic
|
id: semantic
|
||||||
with:
|
with:
|
||||||
@@ -41,77 +53,58 @@ jobs:
|
|||||||
conventional-changelog-eslint
|
conventional-changelog-eslint
|
||||||
branches: |
|
branches: |
|
||||||
[
|
[
|
||||||
'main',
|
'main'
|
||||||
{
|
|
||||||
name: 'alpha',
|
|
||||||
prerelease: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'beta',
|
|
||||||
prerelease: true
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' || needs.semantic_release.outputs.new_release_published == 'true' }}
|
||||||
needs: [extract_environment, semantic_release]
|
needs: [extract_environment, semantic_release]
|
||||||
runs-on: [self-hosted, "${{ needs.extract_environment.outputs.environment }}"]
|
runs-on:
|
||||||
|
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Printing stats
|
||||||
|
env:
|
||||||
|
EVENT: ${{ github.event_name }}
|
||||||
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
|
run: echo ${GITHUB_REF#refs/heads/}
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Update Pip
|
- name: Update Pip
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
|
||||||
- name: Install Docker Compose
|
- name: Install Docker Compose
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install docker-compose --upgrade
|
python3 -m pip install docker-compose --upgrade
|
||||||
|
|
||||||
- name: Install AWS CLI
|
- name: Install AWS CLI
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install awscli --upgrade
|
python3 -m pip install awscli --upgrade
|
||||||
|
|
||||||
- name: Install AWS Elastic Beanstalk CLI
|
- name: Install AWS Elastic Beanstalk CLI
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install awsebcli --upgrade
|
python3 -m pip install awsebcli --upgrade
|
||||||
|
|
||||||
- name: Configure AWS Region
|
- name: Configure AWS Region
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
id: aws
|
id: aws
|
||||||
with:
|
with:
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Extract Environment
|
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "prd")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "dev")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "stg")"
|
|
||||||
fi
|
|
||||||
id: extract_environment
|
|
||||||
|
|
||||||
- name: Login to AWS ECR
|
- name: Login to AWS ECR
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
id: login_ecr
|
id: login_ecr
|
||||||
uses: aws-actions/amazon-ecr-login@v1
|
uses: aws-actions/amazon-ecr-login@v1
|
||||||
|
|
||||||
- name: Build, Tag, and Push Image to AWS ECR
|
- name: Build, Tag, and Push Image to AWS ECR
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@@ -120,9 +113,8 @@ jobs:
|
|||||||
docker-compose -f build.docker-compose.yml push
|
docker-compose -f build.docker-compose.yml push
|
||||||
|
|
||||||
- name: Create ZIP file to Deploy AWS Beanstalk
|
- name: Create ZIP file to Deploy AWS Beanstalk
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||||
run: |
|
run: |
|
||||||
@@ -132,11 +124,10 @@ jobs:
|
|||||||
zip deploy.zip docker-compose.yml -r .ebextensions
|
zip deploy.zip docker-compose.yml -r .ebextensions
|
||||||
|
|
||||||
- name: Deploy AWS Beanstalk
|
- name: Deploy AWS Beanstalk
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
AWS_REGION: us-east-1
|
AWS_REGION: us-east-1
|
||||||
APP_NAME: maestro
|
APP_NAME: ${{ github.event.repository.name }}
|
||||||
run: |
|
run: |
|
||||||
eb use $APP_NAME-$ENV
|
eb use $APP_NAME-$ENV
|
||||||
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
||||||
Generated
+7
-7
@@ -19,7 +19,7 @@
|
|||||||
"@nestjs/platform-express": "^8.4.3",
|
"@nestjs/platform-express": "^8.4.3",
|
||||||
"@nestjs/schedule": "^1.1.0",
|
"@nestjs/schedule": "^1.1.0",
|
||||||
"@nestjs/swagger": "^5.2.1",
|
"@nestjs/swagger": "^5.2.1",
|
||||||
"@victorradael/protospack": "2.3.0",
|
"@victorradael/protospack": "2.4.1-1",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
"dotenv": "^14.2.0",
|
"dotenv": "^14.2.0",
|
||||||
"helmet": "^5.0.2",
|
"helmet": "^5.0.2",
|
||||||
@@ -2359,9 +2359,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@victorradael/protospack": {
|
"node_modules/@victorradael/protospack": {
|
||||||
"version": "2.3.0",
|
"version": "2.4.1-1",
|
||||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.4.1-1.tgz",
|
||||||
"integrity": "sha512-D2iy5Ff8G2FhH6Grs4MHM0qyqc6EU7iGuD3Bit6Tm6GbHmhDbLER9uBowClPjbPSAQ6jP7WTYxwn/TgDK4lNaA==",
|
"integrity": "sha512-QpdnjOiSil1sPvOVuSC1mu5Z76ZDF1+QbDDe/RI3WVWo39dxARBxOxp7/biRY6KLxTPvSUOQbrBAg7Bfx0ul+A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"rxjs": "^7.5.5"
|
"rxjs": "^7.5.5"
|
||||||
}
|
}
|
||||||
@@ -10941,9 +10941,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@victorradael/protospack": {
|
"@victorradael/protospack": {
|
||||||
"version": "2.3.0",
|
"version": "2.4.1-1",
|
||||||
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.4.1-1.tgz",
|
||||||
"integrity": "sha512-D2iy5Ff8G2FhH6Grs4MHM0qyqc6EU7iGuD3Bit6Tm6GbHmhDbLER9uBowClPjbPSAQ6jP7WTYxwn/TgDK4lNaA==",
|
"integrity": "sha512-QpdnjOiSil1sPvOVuSC1mu5Z76ZDF1+QbDDe/RI3WVWo39dxARBxOxp7/biRY6KLxTPvSUOQbrBAg7Bfx0ul+A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"rxjs": "^7.5.5"
|
"rxjs": "^7.5.5"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
"@nestjs/platform-express": "^8.4.3",
|
"@nestjs/platform-express": "^8.4.3",
|
||||||
"@nestjs/schedule": "^1.1.0",
|
"@nestjs/schedule": "^1.1.0",
|
||||||
"@nestjs/swagger": "^5.2.1",
|
"@nestjs/swagger": "^5.2.1",
|
||||||
"@victorradael/protospack": "2.3.0",
|
"@victorradael/protospack": "2.4.1",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
"dotenv": "^14.2.0",
|
"dotenv": "^14.2.0",
|
||||||
"helmet": "^5.0.2",
|
"helmet": "^5.0.2",
|
||||||
|
|||||||
@@ -167,21 +167,18 @@ export class AuthClientService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshAccessToken({
|
async refreshAccessToken({
|
||||||
username,
|
|
||||||
refreshToken,
|
refreshToken,
|
||||||
}: AuthRefreshAccessTokenRequest): Promise<any> {
|
}: AuthRefreshAccessTokenRequest): Promise<any> {
|
||||||
console.log('AuthClientService', 'RefreshAccessToken');
|
console.log('AuthClientService', 'RefreshAccessToken');
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.authService
|
this.authService.refreshAccessToken({ refreshToken }).subscribe({
|
||||||
.refreshAccessToken({ username, refreshToken })
|
next: resolve,
|
||||||
.subscribe({
|
error: (err) => reject(err.details),
|
||||||
next: resolve,
|
complete() {
|
||||||
error: (err) => reject(err.details),
|
console.log('done');
|
||||||
complete() {
|
},
|
||||||
console.log('done');
|
});
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ export class AuthController {
|
|||||||
@Post('refresh-access-token')
|
@Post('refresh-access-token')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async refreshAccessToken(
|
async refreshAccessToken(
|
||||||
@Body() { username, refreshToken }: AuthRefreshAccessTokenRequest,
|
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
|
||||||
) {
|
) {
|
||||||
console.log(`/auth`, 'RefreshAccessToken');
|
console.log(`/auth`, 'RefreshAccessToken');
|
||||||
|
|
||||||
const accessToken = await this.authClient
|
const accessToken = await this.authClient
|
||||||
.refreshAccessToken({ username, refreshToken })
|
.refreshAccessToken({ refreshToken })
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
throw ErrorBuilder(err);
|
throw ErrorBuilder(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import {
|
|||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
Param,
|
Param,
|
||||||
|
Patch,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { InputsService } from './inputs.service';
|
import { InputsService } from './inputs.service';
|
||||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||||
@@ -71,7 +71,7 @@ export class InputsController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Patch(':id')
|
||||||
async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) {
|
async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { info } = updateInputDto;
|
const { info } = updateInputDto;
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
|||||||
export class InputsService {
|
export class InputsService {
|
||||||
constructor(private inputClient: InputsClientService) {}
|
constructor(private inputClient: InputsClientService) {}
|
||||||
|
|
||||||
|
adjustInputPayload(payload) {
|
||||||
|
return payload?.input_s3 || payload?.input_jdbc;
|
||||||
|
}
|
||||||
async create(@Body() data) {
|
async create(@Body() data) {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
@@ -35,8 +38,12 @@ export class InputsService {
|
|||||||
|
|
||||||
async findAll(body) {
|
async findAll(body) {
|
||||||
try {
|
try {
|
||||||
const findAllInputResponse = await this.inputClient.findAll(body);
|
const findAllInputResponse: any = await this.inputClient.findAll(body);
|
||||||
|
if (findAllInputResponse?.inputs?.length) {
|
||||||
|
findAllInputResponse.inputs = findAllInputResponse.inputs.map((input) =>
|
||||||
|
this.adjustInputPayload(input),
|
||||||
|
);
|
||||||
|
}
|
||||||
return findAllInputResponse;
|
return findAllInputResponse;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
@@ -45,7 +52,12 @@ export class InputsService {
|
|||||||
|
|
||||||
async findOne(idRequest: IIdRequest) {
|
async findOne(idRequest: IIdRequest) {
|
||||||
try {
|
try {
|
||||||
const findOneInputResponse = await this.inputClient.findOne(idRequest);
|
const findOneInputResponse: any = await this.inputClient.findOne(
|
||||||
|
idRequest,
|
||||||
|
);
|
||||||
|
findOneInputResponse.input = this.adjustInputPayload(
|
||||||
|
findOneInputResponse.input,
|
||||||
|
);
|
||||||
return findOneInputResponse;
|
return findOneInputResponse;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
@@ -54,12 +66,15 @@ export class InputsService {
|
|||||||
|
|
||||||
async update(id: string, data, info: Info) {
|
async update(id: string, data, info: Info) {
|
||||||
try {
|
try {
|
||||||
const updateInputResponse = await this.inputClient.update({
|
const updateInputResponse: any = await this.inputClient.update({
|
||||||
id,
|
id,
|
||||||
info,
|
info,
|
||||||
...data,
|
...data,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateInputResponse.input = this.adjustInputPayload(
|
||||||
|
updateInputResponse?.input,
|
||||||
|
);
|
||||||
return updateInputResponse;
|
return updateInputResponse;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user