-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (73 loc) · 2.53 KB
/
Diareat-CICD.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
name: Diareat CI/CD
on:
push:
branches: [ "master" ]
paths-ignore:
- 'k8s/**'
permissions:
contents: read
jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
env:
DB_ENDPOINT: ${{ secrets.DB_ENDPOINT }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
with:
arguments: build
- name: Docker login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Build and push to DockerHub
run: |
docker build -t synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }} .
docker push synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }}
CD:
runs-on: ubuntu-latest
needs: CI
steps:
- name: Get version
id: image
run: |
VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Setup Kustomize
uses: imranismail/[email protected]
- name: Checkout kustomize repository
uses: actions/checkout@v3
with:
repository: CAUSOLDOUTMEN/Diareat_backend
ref: master
token: ${{ secrets.ACCESS_TOKEN }}
path: Diareat_backend
- name: Update Kubernetes resources
run: |
cd Diareat_backend/k8s/
kustomize edit set image synoti21/${{ secrets.PROJECT_NAME }}=synoti21/${{ secrets.PROJECT_NAME }}:${{ steps.image.outputs.version }}
kustomize build .
- name: Commit and push the updated manifest
run: |
cd Diareat_backend
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git commit -am ":construction_worker: chore: Update deployment to ${{ github.sha }}"
git push