-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (79 loc) · 2.97 KB
/
gradle.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
# github repository Actions 페이지에 나타낼 이름
name: ACC-hotsix CI/CD
# event trigger
on:
push:
branches: [ "develop" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-22.04
steps:
## jdk setting
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
## gradle caching
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
## create application-prod.yml
- name: create application.yml
run: |
cd ./src/main
cd ./resources
touch ./application.yml
ls *
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
- name: Build with Gradle
run: ./gradlew build -x test
## deploy to production
- name: Configure AWS IAM credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
## docker build
- name: build docker file and setting deploy files
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: acc6-ecr
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
mkdir scripts
touch scripts/deploy.sh
echo "aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $ECR_REGISTRY" >> scripts/deploy.sh
echo "docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
echo "docker run -p 8080:8080 -e PROFILE=dev -d --restart always --name csbroker-api $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
- name: Upload to S3
env:
IMAGE_TAG: ${{ github.sha }}
run: |
zip -r deploy-$IMAGE_TAG.zip ./scripts appspec.yml
aws s3 cp --region ap-northeast-2 --acl private ./deploy-$IMAGE_TAG.zip s3://acc6-s3-dev-an2
- name: Start CodeDeploy Agent
env:
IMAGE_TAG: ${{ github.sha }}
run: >
aws deploy create-deployment --application-name hotsix
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name deploy-group
--s3-location bucket=acc6-s3-dev-an2,bundleType=zip,key=deploy-$IMAGE_TAG.zip