File tree Expand file tree Collapse file tree 2 files changed +93
-0
lines changed
Expand file tree Collapse file tree 2 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ # github repository actions 페이지에 나타날 이름
2+ name : CD to dev using github actions
3+
4+ # event trigger
5+ # develop 브랜치에 pull_request가 닫혔을 때 실행
6+ on :
7+ pull_request :
8+ types : [ closed ]
9+ branches : [ "develop" ]
10+
11+ permissions :
12+ contents : read
13+
14+ jobs :
15+ DEV-CD :
16+ if : github.event.pull_request.merged == true
17+ runs-on : ubuntu-latest
18+ steps :
19+ - name : Download build artifacts
20+ uses : actions/download-artifact@v4
21+ with :
22+ name : build-artifacts
23+
24+ # # docker build & push to production
25+ - name : Docker build & push to prod
26+ run : |
27+ docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
28+ docker build -t ${{ secrets.DOCKER_REPO }} .
29+ docker push ${{ secrets.DOCKER_REPO }}
30+
31+ # # deploy to dev
32+ - name : Deploy to prod
33+ uses : appleboy/ssh-action@master
34+ id : deploy
35+ with :
36+ host : ${{ secrets.DEV_HOST }}
37+ username : ${{ secrets.DEV_HOST_USERNAME }}
38+ key : ${{ secrets.DEV_HOST_KEY }}
39+ port : ${{ secrets.DEV_HOST_PORT }}
40+ script : |
41+ docker rm -f taskflow
42+ docker image rm ${{ secrets.DOCKER_REPO }} -f
43+ docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure
Original file line number Diff line number Diff line change 1+ # github repository actions 페이지에 나타날 이름
2+ name : CI/CD using github actions
3+
4+ # event trigger
5+ # develop 브랜치에 pull_request가 열렸을 때 실행
6+ on :
7+ pull_request :
8+ types : [opened, synchronize, closed]
9+ branches : [ "develop" ]
10+
11+ permissions :
12+ contents : read
13+
14+ jobs :
15+ CI :
16+ if : github.event.action == 'opened' || github.event.action == 'synchronize'
17+ runs-on : ubuntu-latest
18+ steps :
19+ - uses : actions/checkout@v3
20+ - name : ' Set up jdk'
21+ uses : actions/setup-java@v3
22+ with :
23+ java-version : ' 17'
24+ distribution : ' temurin' # https://github.com/actions/setup-java
25+
26+ - run : touch ./Dockerfile
27+ - run : echo "${{ secrets.DEV_DOCKERFILE }}" > ./Dockerfile
28+
29+ # gradle caching - 빌드 시간 향상
30+ - name : Gradle Caching
31+ uses : actions/cache@v3
32+ with :
33+ path : |
34+ ~/.gradle/caches
35+ ~/.gradle/wrapper
36+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
37+ restore-keys : |
38+ ${{ runner.os }}-gradle-
39+
40+ # # gradle build
41+ - name : Build with Gradle
42+ run : |
43+ chmod +x ./gradlew
44+ ./gradlew build
45+
46+ - name : Upload build artifacts
47+ uses : actions/upload-artifact@v4
48+ with :
49+ name : build-artifacts
50+ path : build/libs/*.jar
You can’t perform that action at this time.
0 commit comments