-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.54 KB
/
ecr-push.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
name: CI / CD
on:
push:
branches: [ "main" ]
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew bootJar
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: latest
ACCESS_EXP: ${{ secrets.ACCESS_EXP }}
API_KEY: ${{ secrets.API_KEY }}
API_SECRET: ${{ secrets.API_SECRET }}
BUCKET: ${{ secrets.BUCKET }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_URL: ${{ secrets.DB_URL}}
DB_USER: ${{ secrets.DB_USER }}
DIRECTORY: ${{ secrets.DIRECTORY }}
IAM_ACCESS: ${{ secrets.IAM_ACCESS }}
IAM_SECRET: ${{ secrets.IAM_SECRET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
REFRESH_EXP: ${{ secrets.REFRESH_EXP }}
SENDER: ${{ secrets.SENDER }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
run: |
docker buildx build --platform=linux/amd64 --build-arg ACCESS_EXP=ACCESS_EXP --build-arg API_KEY=API_KEY --build-arg API_SECRET=$API_SECRET --build-arg BUCKET=$BUCKET --build-arg DB_PASSWORD=$DB_PASSWORD --build-arg DB_URL=$DB_URL --build-arg DB_USER=$DB_USER --build-arg DIRECTORY=$DIRECTORY --build-arg IAM_ACCESS=$IAM_ACCESS --build-arg IAM_SECRET=$IAM_SECRET --build-arg JWT_SECRET=$JWT_SECRET --build-arg REFRESH_EXP=$REFRESH_EXP --build-arg SENDER=$SENDER --build-arg REDIS_HOST=$REDIS_HOST -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# - name: Build, tag, and push image to Amazon ECR
# id: build-image
# uses: docker/build-push-action@v3
# with:
# context: .
# push: true
# tags: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY }}:latest