Skip to content

Commit ae42c96

Browse files
authored
Update gradle.yml
1 parent aa38191 commit ae42c96

File tree

1 file changed

+23
-91
lines changed

1 file changed

+23
-91
lines changed

.github/workflows/gradle.yml

Lines changed: 23 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,34 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7-
81
name: Java CI with Gradle
92

103
on:
114
push:
12-
branches: [ "main" ]
5+
branches:
6+
- main
7+
pull_request:
138

149
jobs:
1510
build:
16-
if: github.event.repository.fork == false
1711
runs-on: ubuntu-latest
1812
permissions:
19-
id-token: write
2013
contents: read
21-
2214
steps:
23-
- uses: actions/checkout@v4
24-
- name: Set up JDK 21
25-
uses: actions/setup-java@v4
26-
with:
27-
java-version: '21'
28-
distribution: 'temurin'
29-
30-
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
31-
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
32-
- name: Setup Gradle
33-
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
34-
35-
- name: Build with Gradle Wrapper
36-
run: ./gradlew build
37-
38-
# 3. 도커허브 로그인
39-
- name: Login to DockerHub
40-
uses: docker/login-action@v3
41-
with:
42-
username: ${{ secrets.DOCKER_USERNAME }}
43-
password: ${{ secrets.DOCKER_PASSWORD }}
44-
45-
# 4. 도커 허브에 이미지 푸시
46-
- name: Push Docker Image
47-
uses: docker/build-push-action@v6
48-
with:
49-
push: true
50-
context: .
51-
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
52-
53-
# 5. GCP 인증
54-
- name: Authenticate to GCP
55-
id: 'auth'
56-
uses: 'google-github-actions/auth@v2'
57-
with:
58-
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} # 생성한 워크로드 아이덴티티 풀의 ID
59-
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} # IAM 서비스 계정
60-
61-
# 6. GCP Compute Engine SSH로 배포
62-
- name: Deploy to GCP Compute Engine
63-
id: 'compute-ssh'
64-
uses: 'google-github-actions/ssh-compute@v1'
65-
with:
66-
instance_name: ${{ secrets.GCP_INSTANCE_NAME }}
67-
zone: ${{ secrets.GCP_INSTANCE_ZONE }}
68-
ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
69-
command: |
70-
mkdir ./${{ github.repository }}
71-
cd ./${{ github.repository }}
72-
ls -al
73-
sudo curl -o docker-compose.yml https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.yml
74-
sudo docker-compose down
75-
sudo docker-compose up -d ${{ secrets.DOCKER_IMAGE_NAME }}
76-
sudo docker image prune -a -f
77-
78-
# Example of using the output
79-
- id: 'debug'
80-
run: |-
81-
echo '${{ steps.compute-ssh.outputs.stdout }}'
82-
echo '${{ steps.compute-ssh.outputs.stderr }}'
83-
84-
85-
dependency-submission:
86-
87-
runs-on: ubuntu-latest
88-
permissions:
89-
contents: write
90-
91-
steps:
92-
- uses: actions/checkout@v4
93-
- name: Set up JDK 17
94-
uses: actions/setup-java@v4
95-
with:
96-
java-version: '21'
97-
distribution: 'temurin'
98-
99-
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
100-
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
101-
- name: Generate and submit dependency graph
102-
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v4
25+
26+
- name: Build with Gradle
27+
run: ./gradlew build
28+
29+
# 빌드 결과물을 아티팩트로 업로드 (JAR 파일)
30+
- name: Upload JAR Artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: application-jar
34+
path: build/libs/*.jar

0 commit comments

Comments
 (0)