Skip to content

Commit b5832df

Browse files
authored
New: Github action 적용
1 parent 27f19e5 commit b5832df

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Knowre Android Library CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
types:
8+
- opened
9+
- synchronize
10+
branches: [ "main" ]
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
cache: gradle
25+
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'temurin'
34+
cache: gradle
35+
36+
- name: Gradle Caching
37+
uses: actions/cache@v4.1.0
38+
with:
39+
path: |
40+
~/.gradle/caches
41+
~/.gradle/wrapper
42+
key: ${{ runner.os }}-gradle-${{ github.ref_name }-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
43+
restore-keys: |
44+
${{ runner.os }}-gradle-
45+
46+
- name: Grant execute permission for gradlew
47+
run: chmod +x gradlew
48+
49+
- name: Run unit test
50+
run: ./gradlew testDebugUnitTest
51+
52+
- name: Notify to slack
53+
run: |
54+
STATUS="Build Succeeded!"
55+
COLOR="good"
56+
if [[ ${{ job.status }} == "failure" ]]; then
57+
STATUS="Build Failed!"
58+
COLOR="danger"
59+
elif [[ ${{ job.status }} == "cancelled" ]]; then
60+
STATUS="Build Cancelled!"
61+
COLOR="warning"
62+
fi
63+
64+
BUILD_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run-id }}"
65+
66+
curl -X POST -H 'Content-type: application/json' --data \
67+
'{
68+
"attachments": [
69+
{
70+
"color": "'"$COLOR"'",
71+
"pretext": "'"$STATUS"'",
72+
"fields": [
73+
{
74+
"title": "User",
75+
"value": "${{ github.actor }}",
76+
"short": true
77+
},
78+
{
79+
"title": "Commit Message",
80+
"value": "${{ github.event.head_commit.message }}",
81+
"short": false
82+
},
83+
{
84+
"title": "Branch",
85+
"value": "${{ github.ref_name }}",
86+
"short": true
87+
}
88+
],
89+
"actions": [
90+
{
91+
"type": "button",
92+
"text": "View Build",
93+
"url": "'"${BUILD_URL}"'"
94+
}
95+
]
96+
}
97+
]
98+
}' ${{ secrets.SLACK_WEB_HOOK_URL }}
99+
100+
101+

0 commit comments

Comments
 (0)