-
-
Notifications
You must be signed in to change notification settings - Fork 115
94 lines (79 loc) · 2.84 KB
/
deploy-api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Deploy API
on:
workflow_dispatch:
push:
branches:
- main
paths: ['apps/api/**', '.github/workflows/deploy-api.yml', 'package.json']
jobs:
build:
runs-on: ubuntu-latest
environment: alpha
name: Build and push API docker image for release
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.SECRET_KEY }}
# aws-region: ap-south-1
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
# - name: Build Docker image
# id: build
# env:
# ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
# ECR_REPOSITORY: ${{ vars.ECR_API_REPOSITORY }}
# run: |
# # Build a docker container and push it to ECR
# aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/api/Dockerfile .
# echo "Pushing image to ECR..."
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6}
# echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
# setup-database:
# needs: build
# name: Setup Database
# runs-on: ubuntu-latest
# environment: alpha
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Install Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20
# - name: Install pnpm
# uses: pnpm/action-setup@v4
# with:
# version: 9.2.0
# run_install: false
# - name: Deploy migrations
# env:
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# run: pnpm db:deploy-migrations
# deploy:
# needs: [build, setup-database]
# runs-on: ubuntu-latest
# environment: alpha
# name: Deploy API docker image for release
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.SECRET_KEY }}
# aws-region: ap-south-1
# - name: Force re-deploy task in service
# id: force-redeploy
# env:
# ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
# ECS_SERVICE: ${{ vars.ECS_API_SERVICE }}
# run: |
# aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment