Skip to content

Commit 3a182e4

Browse files
author
Eduardo
committed
chore: change deploy app file
1 parent 0c2cfce commit 3a182e4

File tree

1 file changed

+17
-38
lines changed

1 file changed

+17
-38
lines changed

.github/workflows/DeployApp.yml

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,36 @@
1-
name: Build and Deploy BackendApp to ECS
1+
name: CI/CD Pipeline
22

33
on:
44
push:
55
branches:
66
- master
77

8-
env:
9-
# Setting an environment variable with the value of a configuration variable
10-
ECR_IMAGE: ${{ vars.ECR_IMAGE }}
11-
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
128
jobs:
139
deploy:
1410
runs-on: ubuntu-latest
11+
environment: production
1512

1613
steps:
1714
- name: Checkout repository
1815
uses: actions/checkout@v2
1916

20-
- name: Set up QEMU for arm64
21-
run: |
22-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
23-
if: runner.os == 'Linux'
24-
25-
- name: Set up Docker for arm64
26-
uses: docker/setup-qemu-action@v2
27-
with:
28-
platforms: linux/arm64
29-
30-
- name: Set up Docker
31-
uses: docker/setup-buildx-action@v3
32-
33-
- name: Configure AWS credentials
34-
uses: aws-actions/configure-aws-credentials@v2
17+
- name: Set up SSH
18+
uses: webfactory/[email protected]
3519
with:
36-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
37-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38-
aws-region: sa-east-1
20+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
3921

40-
- name: Login to Amazon ECR
22+
- name: Add SSH host key
4123
run: |
42-
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
24+
mkdir -p ~/.ssh
25+
ssh-keyscan -H ec2-18-228-31-193.sa-east-1.compute.amazonaws.com >> ~/.ssh/known_hosts
4326
44-
- name: Build and push Docker image
27+
- name: Deploy to EC2
4528
run: |
46-
docker buildx create --use
47-
docker buildx inspect --bootstrap
48-
docker buildx build --platform linux/arm64 -t ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$ECR_IMAGE:latest --push .
49-
50-
# - name: Deploy to ECS
51-
# uses: imehedi/actions-awscli-v2@latest
52-
# with:
53-
# args: ecs update-service --cluster MpcsjNestJSStabilityIntegration --service MpcsjStabilityAPI --force-new-deployment
54-
# env:
55-
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
56-
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
57-
# AWS_DEFAULT_REGION: 'sa-east-1'
29+
ssh [email protected] << 'EOF'
30+
cd /chaxis-api
31+
git pull origin master
32+
npm install
33+
npx prisma migrate deploy
34+
npm run prebuild
35+
npm run build
36+
EOF

0 commit comments

Comments
 (0)