-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 1.69 KB
/
spring-boot-ci.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
59
60
61
62
63
name: Spring Boot CI with Gradle
on:
push:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Create application-private.properties
run: |
cd ./src/main/resources
touch ./application-private.properties
echo "${{ secrets.SPRING_BE_APPLICATION_PRIVATE }}" >> ./application-private.properties
shell: bash
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew bootJar
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.ORG_JUDEMIN_DOCKERHUB_USERNAME }}
password: ${{ secrets.ORG_JUDEMIN_DOCKERHUB_PASSWORD }}
- name: Set Docker Image Tag
id: docker_tag
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [ "$BRANCH_NAME" == "main" ]; then
TAG="latest"
else
# 도커 태그로 사용할 수 없는 문자 치환
TAG=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]._-')
fi
echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV
- name: Docker build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: judemin/wwwm-spring-be:${{ env.DOCKER_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max