-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (81 loc) · 3.15 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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
# JDK를 17 버전으로 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Gradle 캐싱-> 빌드 속도 UP
- name: Gradle caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# application.yml 파일 생성
- name: make application.yaml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
shell: bash
# Gradle로 빌드 실행
- name: Build with Gradle
run: ./gradlew bootJar
# image로부터 Metadata 추출
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
tags: |
type=sha
# image 빌드 및 도커허브에 push
- name: web docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }}
docker build -t ${{ secrets.DOCKER_REPO }}/seniors:${{ steps.meta.outputs.version }} .
docker push ${{ secrets.DOCKER_REPO }}/seniors:${{ steps.meta.outputs.version }}
# manifest file 존재하는 Repository clone and checkout
- name: Clone and Checkout to config Repository
uses: actions/checkout@v3
with:
repository: seniors-project/backend-config
token: ${{ secrets.HELMREPO }}
# yq 사용해 yaml file edit
- name: Change config repo values.yaml
uses: mikefarah/yq@master
with:
cmd: yq -i '.image.tag = "${{ steps.meta.outputs.version }}"' seniors/values.yaml
# config repo의 image version update
- name: Pushes to config repository
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.HELMREPO }}
with:
source-directory: "."
destination-github-username: "seniors-project"
destination-repository-name: "backend-config"
user-email: [email protected]
target-branch: main
commit-message: "Update Image version to ${{ steps.meta.outputs.version }}"