Update main.yml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI CD with Gradle | |
on: | |
workflow_dispatch: # 수동 실행 트리거 | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 워크플로우가 Ubuntu 최신 버전에서 실행 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 # 리포지토리의 코드를 체크아웃 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set Gradle Wrapper executable | |
run: chmod +x ./gradlew | |
- name: Execute remote ssh commands | |
uses: appleboy/ssh-action@master # ssh 연결을 위한 오픈 소스 액션 | |
with: | |
host: ${{ secrets.REMOTE_IP }} # 인스턴스 IP | |
username: ${{ secrets.REMOTE_USER }} # 우분투 ID | |
key: ${{ secrets.REMOTE_PRIVATE_KEY }} # EC2 인스턴스 pem key | |
port: ${{ secrets.REMOTE_SSH_PORT }} # 접속 포트 | |
script: | # 실행할 스크립트 | |
cd ./apap-back/cicd | |
git pull origin main | |
touch ./src/main/resources/application.properties # application.properties 파일 생성 | |
echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.properties | |
cat ./src/main/resources/application.properties | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@v3 | |
with: | |
arguments: build | |
gradle-version: '8.6' |