-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (54 loc) · 1.85 KB
/
ci.yml
File metadata and controls
62 lines (54 loc) · 1.85 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
name: ci.yml
on:
workflow_dispatch:
push:
branches: [ develop ]
paths-ignore:
- '.github/workflows/cd.yml' # 워크플로우 수정만 있을 때는 빌드 스킵
- 'README.md'
jobs:
# 1. 빌드 + 이미지 빌드 & 푸시
build:
runs-on: ubuntu-latest
steps:
- name: Decode and export env vars
run: |
echo "${{ secrets.APP_ENV_B64 }}" | base64 --decode | tr -d '\r'> .env
# .env 내용을 GitHub Actions 환경변수로 export
while IFS='=' read -r key value; do
if [[ ! -z "$key" && ! "$key" =~ ^# ]]; then
echo "$key=$value" >> $GITHUB_ENV
fi
done < .env
- name: Check out code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Build (no Test)
run: ./gradlew clean bootJar --no-daemon
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.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: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ env.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
echo "tag: $IMAGE_TAG"
docker buildx build \
--platform linux/amd64 \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
--push .
# 태그관리: latest, github hash