-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (85 loc) · 2.95 KB
/
deploy.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Deploy
on:
workflow_dispatch:
inputs:
tags:
description: 'Container tag name'
required: true
type: choice
options:
- latest
- develop
default: develop
env:
AWS_REGION: ap-northeast-2
jobs:
build:
runs-on: ubuntu-20.04
env:
SPRING_PROFILES_ACTIVE: ${{ github.event.inputs.tags == 'latest' && 'prod' || 'dev' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Test profile
run: echo $SPRING_PROFILES_ACTIVE
- uses: keithweaver/[email protected] # Verifies the recursive flag
name: sync folder
with:
command: sync
source: ${{ secrets.S3_BUCKET }}
destination: ./src/main/resources/
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: 17
distribution: 'corretto'
java-package: 'jdk'
- name: Cache Gradle modules
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Check style
run: ./gradlew checkstyle
- name: Test with Gradle
run: ./gradlew test
- name: Build with Gradle
run: ./gradlew build
- name: Set PROJECT_NAME and PROJECT_VERSION from Gradle
id: set-env
run: |
echo "PROJECT_NAME=$(./gradlew properties | grep '^name:' | awk '{print $2}')" >> "$GITHUB_ENV"
echo "PROJECT_VERSION=$(./gradlew properties | grep '^version:' | awk '{print $2}')" >> "$GITHUB_ENV"
shell: bash
- 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: ${{ env.AWS_REGION }}
- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build and Push
id: build-push
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ inputs.tags }}
${{ env.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{env.PROJECT_VERSION}}
build-args: |
jarFile=./build/libs/${{ env.PROJECT_NAME }}-${{ env.PROJECT_VERSION }}.jar