-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (83 loc) · 3.1 KB
/
admin-ci-cd.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
95
96
97
name: Admin-Module CI/CD
on:
push:
branches: [ main, develop ]
paths:
- 'sluv-admin/**'
- 'sluv-domain/**'
- 'sluv-common/**'
- 'sluv-infra/**'
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: false
jobs:
admin-ci-cd:
runs-on: ubuntu-latest
steps:
- name: Checkout Latest Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.TOKEN_OF_GITHUB }}
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew :sluv-admin:clean :sluv-admin:build
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
docker build -t sluv-springboot-${{ github.ref_name }}-admin-module sluv-admin/.
docker tag sluv-springboot-${{ github.ref_name }}-admin-module sluv2323/sluv-springboot-${{ github.ref_name }}-admin-module:latest
docker push sluv2323/sluv-springboot-${{ github.ref_name }}-admin-module:latest
- name: Get timestamp
uses: gerred/actions/current-time@master
id: current-time
- name: Run string replace
uses: frabert/replace-string-action@master
id: format-time
with:
pattern: '[:\.]+'
string: "${{ steps.current-time.outputs.time }}"
replace-with: '-'
flags: 'g'
- name: Deploy to Local Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LOCAL_SERVER_HOST }}
username: ${{ secrets.LOCAL_SERVER_USER }}
password: ${{ secrets.LOCAL_SERVER_SSH_PASSWORD }}
script: |
branchName=${{ github.ref_name }}
echo ${branchName}
echo ${{ secrets.LOCAL_SERVER_SUDO_PASSWORD }} | sudo -S chmod +x /home/sluv/${branchName}-server/${branchName}-deploy-script.sh
echo "chmod Clear"
echo ${{ secrets.LOCAL_SERVER_SUDO_PASSWORD }} | sudo -S /home/sluv/${branchName}-server/${branchName}-deploy-script.sh
echo "Process Clear"
current-time:
needs: admin-ci-cd
runs-on: ubuntu-latest
steps:
- name: Get Current Time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH:mm:ss
utcOffset: "+09:00" # 기준이 UTC이기 때문에 한국시간인 KST를 맞추기 위해 +9시간 추가
- name: Print Current Time
run: echo "Current Time=${{steps.current-time.outputs.formattedTime}}" # current-time 에서 지정한 포맷대로 현재 시간 출력
shell: bash
## discord
action-discord:
needs: admin-ci-cd
runs-on: ubuntu-latest
steps:
- name: Discord Alarm
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: "Dev ${{ github.ref_name }} Admin-Module Deploy ${{ job.status }}"