Skip to content

Commit eb5bc5c

Browse files
authored
깃헙 액션 수동배포 추가, 모듈화 (#475)
1 parent 59f9f7e commit eb5bc5c

12 files changed

+260
-272
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: deploy-native-template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
target_branch:
7+
required: false
8+
type: string
9+
default: ''
10+
ecr_repository:
11+
required: true
12+
type: string
13+
dockerfile:
14+
required: true
15+
type: string
16+
description: 'Dockerfile path (e.g., api/Dockerfile-native)'
17+
secrets:
18+
AWS_ACCESS_KEY_ID:
19+
required: true
20+
AWS_SECRET_ACCESS_KEY:
21+
required: true
22+
23+
jobs:
24+
deploy:
25+
name: Deploy Native
26+
runs-on: ubuntu-24.04-arm
27+
28+
env:
29+
IMAGE_TAG: ${{ github.run_number }}
30+
BUILD_NUMBER: ${{ github.run_number }}
31+
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
32+
ECR_REPOSITORY: ${{ inputs.ecr_repository }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ inputs.target_branch || github.ref }}
39+
40+
- name: Configure AWS credentials
41+
uses: aws-actions/configure-aws-credentials@v4
42+
with:
43+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
44+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
45+
aws-region: ap-northeast-2
46+
47+
- name: Login to ECR
48+
id: login-ecr
49+
uses: aws-actions/amazon-ecr-login@v2
50+
51+
- name: Get and save Auth Token for CodeArtifact
52+
id: get-save-codeartifact-auth-token
53+
run: |
54+
aws codeartifact get-authorization-token \
55+
--domain wafflestudio \
56+
--domain-owner 405906814034 \
57+
--query authorizationToken \
58+
--region ap-northeast-1 \
59+
--output text > .codeartifact_token
60+
61+
- name: Docker build, tag, and push image to ECR
62+
id: build-push-image
63+
run: |
64+
docker build \
65+
--secret id=codeartifact_token,src=./.codeartifact_token \
66+
-f ${{ inputs.dockerfile }} \
67+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
68+
. \
69+
--platform linux/arm64
70+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
71+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
72+

.github/workflows/_deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: deploy-template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
target_branch:
7+
required: false
8+
type: string
9+
default: ''
10+
ecr_repository:
11+
required: true
12+
type: string
13+
dockerfile:
14+
required: true
15+
type: string
16+
description: 'Dockerfile path (e.g., api/Dockerfile)'
17+
secrets:
18+
AWS_ACCESS_KEY_ID:
19+
required: true
20+
AWS_SECRET_ACCESS_KEY:
21+
required: true
22+
23+
jobs:
24+
deploy:
25+
name: Deploy
26+
runs-on: ubuntu-24.04-arm
27+
28+
env:
29+
IMAGE_TAG: ${{ github.run_number }}
30+
BUILD_NUMBER: ${{ github.run_number }}
31+
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
32+
ECR_REPOSITORY: ${{ inputs.ecr_repository }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ inputs.target_branch || github.ref }}
39+
40+
- name: Configure AWS credentials
41+
uses: aws-actions/configure-aws-credentials@v4
42+
with:
43+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
44+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
45+
aws-region: ap-northeast-2
46+
47+
- name: Login to ECR
48+
id: login-ecr
49+
uses: aws-actions/amazon-ecr-login@v2
50+
51+
- name: Get and save Auth Token for CodeArtifact
52+
id: get-save-codeartifact-auth-token
53+
run: |
54+
aws codeartifact get-authorization-token \
55+
--domain wafflestudio \
56+
--domain-owner 405906814034 \
57+
--query authorizationToken \
58+
--region ap-northeast-1 \
59+
--output text > .codeartifact_token
60+
61+
- name: Docker build, tag, and push image to ECR
62+
id: build-push-image
63+
run: |
64+
docker build \
65+
--secret id=codeartifact_token,src=./.codeartifact_token \
66+
-f ${{ inputs.dockerfile }} \
67+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
68+
. \
69+
--platform linux/arm64
70+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
71+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

.github/workflows/deploy-api-dev-native.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,10 @@ on:
66

77
jobs:
88
deploy:
9-
name: Deploy-api-dev-native
10-
runs-on: ubuntu-24.04-arm
11-
env:
12-
IMAGE_TAG: ${{ github.run_number }}
13-
BUILD_NUMBER: ${{ github.run_number }}
14-
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
15-
ECR_REPOSITORY: snutt-dev/snutt-timetable
16-
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ap-northeast-2
27-
28-
- name: Login to ECR
29-
id: login-ecr
30-
uses: aws-actions/amazon-ecr-login@v2
31-
32-
- name: Get and save Auth Token for CodeArtifact
33-
id: get-save-codeartifact-auth-token
34-
run: |
35-
aws codeartifact get-authorization-token --domain wafflestudio --domain-owner 405906814034 --query authorizationToken --region ap-northeast-1 --output text > .codeartifact_token
36-
37-
- name: Docker build, tag, and push image to ECR
38-
id: build-push-image
39-
run: |
40-
docker build --secret id=codeartifact_token,src=./.codeartifact_token -f api/Dockerfile-native -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --platform linux/arm64
41-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
42-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
9+
uses: ./.github/workflows/_deploy-native.yml
10+
with:
11+
ecr_repository: snutt-dev/snutt-timetable
12+
dockerfile: api/Dockerfile-native
13+
secrets:
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/deploy-api-dev.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,10 @@ on:
66

77
jobs:
88
deploy:
9-
name: Deploy-api-dev
10-
runs-on: ubuntu-24.04-arm
11-
env:
12-
IMAGE_TAG: ${{ github.run_number }}
13-
BUILD_NUMBER: ${{ github.run_number }}
14-
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
15-
ECR_REPOSITORY: snutt-dev/snutt-timetable
16-
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ap-northeast-2
27-
28-
- name: Login to ECR
29-
id: login-ecr
30-
uses: aws-actions/amazon-ecr-login@v2
31-
32-
- name: Get and save Auth Token for CodeArtifact
33-
id: get-save-codeartifact-auth-token
34-
run: |
35-
aws codeartifact get-authorization-token --domain wafflestudio --domain-owner 405906814034 --query authorizationToken --region ap-northeast-1 --output text > .codeartifact_token
36-
37-
- name: Docker build, tag, and push image to ECR
38-
id: build-push-image
39-
run: |
40-
docker build --secret id=codeartifact_token,src=./.codeartifact_token -f api/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --platform linux/arm64
41-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
42-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
9+
uses: ./.github/workflows/_deploy.yml
10+
with:
11+
ecr_repository: snutt-dev/snutt-timetable
12+
dockerfile: api/Dockerfile
13+
secrets:
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/deploy-api-prod-native.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,10 @@ on:
66

77
jobs:
88
deploy:
9-
name: Deploy-api-prod-native
10-
runs-on: ubuntu-24.04-arm
11-
env:
12-
IMAGE_TAG: ${{ github.run_number }}
13-
BUILD_NUMBER: ${{ github.run_number }}
14-
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
15-
ECR_REPOSITORY: snutt-prod/snutt-timetable
16-
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ap-northeast-2
27-
28-
- name: Login to ECR
29-
id: login-ecr
30-
uses: aws-actions/amazon-ecr-login@v2
31-
32-
- name: Get and save Auth Token for CodeArtifact
33-
id: get-save-codeartifact-auth-token
34-
run: |
35-
aws codeartifact get-authorization-token --domain wafflestudio --domain-owner 405906814034 --query authorizationToken --region ap-northeast-1 --output text > .codeartifact_token
36-
37-
- name: Docker build, tag, and push image to ECR
38-
id: build-push-image
39-
run: |
40-
docker build --secret id=codeartifact_token,src=./.codeartifact_token -f api/Dockerfile-native -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --platform linux/arm64
41-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
42-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
9+
uses: ./.github/workflows/_deploy-native.yml
10+
with:
11+
ecr_repository: snutt-prod/snutt-timetable
12+
dockerfile: api/Dockerfile-native
13+
secrets:
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/deploy-api-prod.yml

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,18 @@ on:
66

77
jobs:
88
deploy:
9-
name: Deploy-api-prod
10-
runs-on: ubuntu-24.04-arm
11-
env:
12-
IMAGE_TAG: ${{ github.run_number }}
13-
BUILD_NUMBER: ${{ github.run_number }}
14-
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
15-
ECR_REPOSITORY: snutt-prod/snutt-timetable
16-
9+
uses: ./.github/workflows/_deploy.yml
10+
with:
11+
ecr_repository: snutt-prod/snutt-timetable
12+
dockerfile: api/Dockerfile
13+
secrets:
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16+
17+
notify:
18+
needs: deploy
19+
runs-on: ubuntu-latest
1720
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ap-northeast-2
27-
28-
- name: Login to ECR
29-
id: login-ecr
30-
uses: aws-actions/amazon-ecr-login@v2
31-
32-
- name: Get and save Auth Token for CodeArtifact
33-
id: get-save-codeartifact-auth-token
34-
run: |
35-
aws codeartifact get-authorization-token --domain wafflestudio --domain-owner 405906814034 --query authorizationToken --region ap-northeast-1 --output text > .codeartifact_token
36-
37-
- name: Docker build, tag, and push image to ECR
38-
id: build-push-image
39-
run: |
40-
docker build --secret id=codeartifact_token,src=./.codeartifact_token -f api/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --platform linux/arm64
41-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
42-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
43-
4421
- name: Slack Notify
4522
uses: rtCamp/action-slack-notify@v2.3.3
4623
env:

.github/workflows/deploy-batch-dev-native.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,10 @@ on:
66

77
jobs:
88
deploy:
9-
name: Deploy-batch-dev-native
10-
runs-on: ubuntu-24.04-arm
11-
env:
12-
IMAGE_TAG: ${{ github.run_number }}
13-
BUILD_NUMBER: ${{ github.run_number }}
14-
ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com
15-
ECR_BATCH_REPOSITORY: snutt-dev/snutt-timetable-batch
16-
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ap-northeast-2
27-
28-
- name: Login to ECR
29-
id: login-ecr
30-
uses: aws-actions/amazon-ecr-login@v2
31-
32-
- name: Get and save Auth Token for CodeArtifact
33-
id: get-save-codeartifact-auth-token
34-
run: |
35-
aws codeartifact get-authorization-token --domain wafflestudio --domain-owner 405906814034 --query authorizationToken --region ap-northeast-1 --output text > .codeartifact_token
36-
37-
- name: Docker build, tag, and push image to ECR
38-
id: build-push-image
39-
run: |
40-
docker build --secret id=codeartifact_token,src=./.codeartifact_token -f batch/Dockerfile-native -t $ECR_REGISTRY/$ECR_BATCH_REPOSITORY:$IMAGE_TAG . --platform linux/arm64
41-
docker push $ECR_REGISTRY/$ECR_BATCH_REPOSITORY:$IMAGE_TAG
42-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
9+
uses: ./.github/workflows/_deploy-native.yml
10+
with:
11+
ecr_repository: snutt-dev/snutt-timetable-batch
12+
dockerfile: batch/Dockerfile-native
13+
secrets:
14+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

0 commit comments

Comments
 (0)