Skip to content

Commit

Permalink
feat: cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
de-novo committed May 9, 2024
1 parent a2068eb commit 3eb156a
Show file tree
Hide file tree
Showing 11 changed files with 5,462 additions and 7,003 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ on:
description: 'Service'
required: true
type: string

secrets:
SLACK_WEBHOOK_URL:
description: 'Slack Webhook URL'
required: true

DOPPLER_TOKEN:
description: 'Doppler Token'
required: true
AWS_IAM_ROLE_ARN:
description: 'AWS IAM Role ARN'
required: true
permissions:
id-token: write
contents: read
Expand All @@ -35,16 +41,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: doppler Install CLI
uses: dopplerhq/cli-action@v3

- name: download env
run: doppler secrets download --no-file --format env > .env
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
# role-to-assume: arn:aws:iam::<alias>:role/github-action-role
role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN }}
aws-region: ap-northeast-2

- name: Download env file
run: |
aws s3 cp s3://{}/${{ inputs.PHASE }}/${{ inputs.SERVICE }}/server.env .env
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'dev api - test and deploy'
on:
push:
branches:
- dev

permissions:
id-token: write
contents: read

jobs:
test:
uses: ./.github/workflows/test.yml
with:
node-version: '20.5.1'
pnpm-version: '8'

build-and-deploy:
uses: ./.github/workflows/deploy.yml
with:
ECR_REPOSITORY: 'service-api'
PHASE: 'dev'
SERVICE: 'api'

secrets:
AWS_IAM_ROLE_ARN: ${{ secrets.AWS_IAM_ROLE_ARN }}
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN_DEV }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
47 changes: 47 additions & 0 deletions deploy/dev/task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"taskRoleArn": "arn:aws:iam::339712777001:role/dev-service-api-task-role",
"executionRoleArn": "arn:aws:iam::339712777001:role/dev-service-api-exec-role",
"containerDefinitions": [
{
"name": "dev-service-api",
"image": "",
"cpu": 0,
"links": [],
"portMappings": [
{
"containerPort": 8000,
"hostPort": 8000,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"dockerSecurityOptions": [],
"ulimits": [
{
"name": "nofile",
"softLimit": 65535,
"hardLimit": 65535
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/aws/ecs/dev-service-api",
"awslogs-region": "ap-northeast-2",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
},
"systemControls": []
}
],
"requiresCompatibilities": ["FARGATE"],
"networkMode": "awsvpc",
"cpu": "256",
"memory": "512",
"family": "dev-service-api"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-express": "^10.0.0",
"@prisma/client": "5.12.1",
"@prisma/client": "5.13.0",
"bcrypt": "^5.1.1",
"cache-manager": "^5.5.1",
"cache-manager-redis-store": "^3.0.1",
"cookie-parser": "^1.4.6",
"joi": "^17.12.3",
"nestjs-twilio": "^4.4.0",
"prisma": "^5.11.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"typia": "^5.5.7",
Expand Down Expand Up @@ -75,6 +74,7 @@
"lint-staged": "^15.2.2",
"nestia": "^5.3.0",
"prettier": "^3.0.0",
"prisma": "^5.13.0",
"prisma-markdown": "^1.0.9",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
Expand Down
Loading

0 comments on commit 3eb156a

Please sign in to comment.