-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (92 loc) · 3.4 KB
/
build.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
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
102
103
104
105
106
name: Docker Build 🚀
on:
push:
branches: [ "master" ]
workflow_dispatch:
inputs:
branch:
description: 'Select a branch to build'
required: true
default: develop
type: choice
options:
- develop # Manual build option for develop branch
jobs:
gradle:
name: Image Build
runs-on: ubuntu-22.04
environment: dev
env:
image_name: ${{ secrets.DOCKER_REPO }}/docker/711-community
image_tag: ${{ github.sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || github.ref }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Set Timezone to Asia/Seoul
run: |
sudo ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
echo "Asia/Seoul" | sudo tee /etc/timezone
shell: bash
- name: make application-hidden.yaml
run: |
cd ./src/main/resources
touch ./application-hidden.yaml
echo "${{ secrets.hidden }}" >> ./application-hidden.yaml
shell: bash
- name: make application-hidden-dev.yaml
run: |
cd ./src/main/resources
touch ./application-hidden-dev.yaml
echo "${{ secrets.hidden_dev }}" >> ./application-hidden-dev.yaml
shell: bash
- name: Cache Gradle packages
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
- name: Test with Gradle
run: SPRING_PROFILES_ACTIVE=dev ./gradlew test
- name: Build with Gradle
run: ./gradlew build -x test
- name: Building Docker Image
run: |
docker login ${{ secrets.DOCKER_REPO }} -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ env.image_name }}:${{ env.image_tag }} -t ${{ env.image_name }}:latest .
docker push ${{ env.image_name }}:${{ env.image_tag }}
docker push ${{ env.image_name }}:latest
deployment:
name: Argo Deployment
runs-on: ubuntu-22.04
needs: gradle
environment: dev
env:
branch_name: helm
image_tag: ${{ github.sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.branch_name }}
submodules: 'recursive' # Actions -> General -> Workflow permissions (add write)
token: ${{ secrets.GITHUB_TOKEN }} # Ensure the token is being used
- name: Change values.yaml
run: |
sed -i "s/tag: \".*\"/tag: \"${{ env.image_tag }}\"/g" values.yaml
- name: Git Push
run: |
git config --global user.email "GitHub Actions [email protected]"
git config --global user.name "GitHub Actions Bot"
git add values.yaml
git commit -m "change image tag: ${{ env.image_tag }}"
git -c http.extraHeader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" pull --rebase origin ${{ env.branch_name }}
git -c http.extraHeader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" push origin ${{ env.branch_name }}