-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (80 loc) · 2.47 KB
/
ci-develop.yml
File metadata and controls
98 lines (80 loc) · 2.47 KB
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
name: ci-develop
on:
push:
branches: [ "develop" ]
workflow_dispatch:
permissions:
contents: read
env:
IMAGE_NAME: ghcr.io/danuri-team/danuri-backend
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean bootJar
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./DockerfileStage
push: true
platforms: linux/arm64
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
- name: Checkout kustomize repository
uses: actions/checkout@v4
with:
repository: danuri-team/danuri-devops
ref: main
token: ${{ secrets.ACTION_TOKEN }}
path: danuri-devops
- name: Update Kubernetes resources
run: |
cd danuri-devops/danuri-backend/overlays/stage/
kustomize edit set image ${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }}
cat kustomization.yaml
- name: Commit files
run: |
cd danuri-devops
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions"
git commit -am "Update image tag"
git push -u origin main