Skip to content

Commit 85e2657

Browse files
committed
Fix: gradle.yml 수정
- 더 이상 사용하지 않을 스크립트 파일 삭제 - appspec.yml 수정
1 parent 77dcba6 commit 85e2657

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

.github/workflows/gradle.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333
${{ runner.os }}-gradle-
3434
3535
- name: Grant execute permission for gradlew
36-
run:
37-
chmod +x gradlew
36+
run: chmod +x gradlew
3837

3938
## create application-prod.yml
4039
- name: create application.yml
@@ -48,22 +47,6 @@ jobs:
4847
- name: Build with Gradle
4948
run: ./gradlew build -x test
5049

51-
## docker build & push to production
52-
- name: Build Docker image
53-
run: docker build --tag acchotsix/acc-hotsix:latest .
54-
55-
- name: Log in to DockerHub
56-
uses: docker/[email protected]
57-
with:
58-
username: ${{ secrets.DOCKER_USERNAME }}
59-
password: ${{ secrets.DOCKER_PASSWORD }}
60-
61-
- name: Push image to DockerHub
62-
run: docker push acchotsix/acc-hotsix:latest
63-
64-
- name: Make zip file
65-
run: zip -r ./hotsix.zip .
66-
6750
## deploy to production
6851
- name: Configure AWS IAM credentials
6952
uses: aws-actions/configure-aws-credentials@v1
@@ -72,12 +55,39 @@ jobs:
7255
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
7356
aws-region: ap-northeast-2
7457

58+
- name: Login to ECR
59+
id: login-ecr
60+
uses: aws-actions/amazon-ecr-login@v1
61+
62+
## docker build
63+
- name: build docker file and setting deploy files
64+
env:
65+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
66+
ECR_REPOSITORY: acc6-ecr
67+
IMAGE_TAG: ${{ github.sha }}
68+
run: |
69+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
70+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
71+
mkdir scripts
72+
touch scripts/deploy.sh
73+
echo "aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $ECR_REGISTRY" >> scripts/deploy.sh
74+
echo "docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
75+
echo "docker run -p 8080:8080 -e PROFILE=dev -d --restart always --name csbroker-api $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
76+
7577
- name: Upload to S3
76-
run: aws s3 cp --region ap-northeast-2 ./hotsix.zip s3://acc6-s3-dev-an2/hotsix.zip #버킷에 업로드.
78+
env:
79+
IMAGE_TAG: ${{ github.sha }}
80+
run: |
81+
zip -r deploy-$IMAGE_TAG.zip ./scripts appspec.yml
82+
aws s3 cp --region ap-northeast-2 --acl private ./deploy-$IMAGE_TAG.zip s3://acc6-s3-dev-an2
7783
7884
- name: Start CodeDeploy Agent
79-
run: >
80-
aws deploy create-deployment --application-name hotsix
81-
--deployment-config-name CodeDeployDefault.AllAtOnce
85+
env:
86+
IMAGE_TAG: ${{ github.sha }}
87+
run: |
88+
aws deploy create-deployment
89+
--application-name hotsix
8290
--deployment-group-name deploy-group
83-
--s3-location bucket=acc6-s3-dev-an2,bundleType=zip,key=hotsix.zip
91+
--deployment-config-name CodeDeployDefault.AllAtOnce
92+
--s3-location bucket=acc6-s3-dev-an2,bundleType=zip,key=deploy-$IMAGE_TAG.zip
93+
--debug

appspec.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ version: 0.0
22
os: linux
33
files:
44
- source: /
5-
destination: /home/ubuntu
5+
destination: /home/ubuntu/app
66
overwrite: yes
77

88
permissions:
9-
- object: /home/ubuntu
9+
- object: /
1010
pattern: "**"
11-
owner: root
12-
group: root
11+
owner: ubuntu
12+
group: ubuntu
13+
mode: 755
1314

1415
hooks:
15-
ApplicationStart:
16-
- location: scripts/run_docker.sh
17-
timeout: 120
18-
runas: root
16+
AfterInstall:
17+
- location: scripts/deploy.sh
18+
timeout: 60
19+
runas: ubuntu

scripts/run_docker.sh

-3
This file was deleted.

0 commit comments

Comments
 (0)