Skip to content

Commit 2d10eda

Browse files
authored
Merge pull request #2 from prgrms-web-devcourse-final-project/feature/github-action
Chore: Main PR, 데일리 아키이빙 yml 파일 추가
2 parents 49804d1 + 7f8bd7f commit 2d10eda

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: log4u-build
2+
on:
3+
# push:
4+
# branches:
5+
# - dev # dev 브랜치 push
6+
pull_request:
7+
branches:
8+
- main # main pr
9+
types: [ opened, synchronize, reopened ]
10+
jobs:
11+
build:
12+
name: Build and analyze
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: 21
22+
distribution: 'zulu' # Alternative distribution options are available
23+
- name: Cache Gradle packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.gradle/caches
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
28+
restore-keys: ${{ runner.os }}-gradle
29+
- name: Cache SonarCloud packages
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.sonar/cache
33+
key: ${{ runner.os }}-sonar
34+
restore-keys: ${{ runner.os }}-sonar
35+
- name: Build and analyze
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
38+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39+
DB_URL: ${{ secrets.DB_URL }} # Database URL
40+
DB_USERNAME: ${{ secrets.DB_USERNAME }} # Database username
41+
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} # Database password
42+
run: |
43+
chmod +x ./gradlew
44+
./gradlew build jacocoTestReport sonar --info
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Archive dev branch daily
2+
3+
on:
4+
schedule:
5+
- cron: "59 14 * * *" # 한국 시간(KST) 23:59 (UTC+14:59)
6+
workflow_dispatch: # 수동 실행 가능
7+
8+
jobs:
9+
archive:
10+
name: Archive dev branch
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # 모든 브랜치 가져오기
18+
19+
- name: Set archive branch name
20+
id: date
21+
run: echo "BRANCH_NAME=archive-$(date +'%Y-%m-%d')" >> $GITHUB_ENV
22+
23+
- name: Create new archive branch
24+
run: |
25+
git checkout dev
26+
git pull origin dev
27+
git checkout -b ${{ env.BRANCH_NAME }}
28+
git push origin ${{ env.BRANCH_NAME }}

0 commit comments

Comments
 (0)