-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (60 loc) · 2.24 KB
/
dev-ci-cd.yml
File metadata and controls
71 lines (60 loc) · 2.24 KB
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
name: Dev CI/CD - Build, Push and Deploy
on:
push:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: sopt-makers/crew-dev
IMAGE_TAG: development-latest
SPRING_PROFILES_ACTIVE: dev
jobs:
build-push-and-deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
environment: development
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Inject application-secret.properties from Secrets
run: |
echo "${{ secrets.APPLICATION_SECRET_SPRING }}" > ./main/src/main/resources/application-secret.properties
shell: bash
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./main
file: ./main/Dockerfile
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SPRING_PROFILES_ACTIVE=${{ env.SPRING_PROFILES_ACTIVE }}
- name: Deploy to Development Server
uses: appleboy/ssh-action@v1.2.2
with:
host: ${{ secrets.DEV_SERVER_IP }}
username: ${{ secrets.DEV_SERVER_USER }}
key: ${{ secrets.DEV_SERVER_KEY }}
script: |
sudo aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ steps.login-ecr.outputs.registry }}
export IMAGE_NAME="${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
cd ~/crew
chmod +x ./deploy.sh
./deploy.sh