-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.75 KB
/
deploy.yaml
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
name: Deploy to Amazon ECR
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
name: Build and Push Docker image to Amazon ECR
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ github.run_number }}
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: set credentials
uses: microsoft/variable-substitution@v1
with:
files: './src/main/resources/application-prod.yaml'
env:
spring.datasource.url: ${{ secrets.AWS_DATASOURCE_URL }}
spring.datasource.username: ${{ secrets.AWS_RDS_USERNAME }}
spring.datasource.password: ${{ secrets.AWS_RDS_PASSWORD }}
spring.data.redis.host: ${{ secrets.AWS_ELASTICACHE_HOST }}
spring.data.redis.database: ${{ secrets.AWS_ELASTICACHE_DATABASE }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
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: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG