Merge pull request #45 from TogetherWithOcean-TWO/SCRUM-117-pwEncodePlus #42
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
# 1 워크플로의 이름 지정 | |
name: main | |
# 2 워크플로가 시작될 조건 지정 | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 3 실행 환경 지정 | |
#4 실행 스텝 지정 | |
# uses: uses 키워드는 지정한 리포지토리를 확인하고 코드에 대한 작업을 실행할 수 있습니다. | |
# action/check-out에는 checkout이라는 작업의 v3 버전을 실행합니다. | |
# name: 스텝의 이름을 지정합니다. | |
# run: run 키워드는 실행할 명령어를 입력합니다. | |
# ./gradlew clean build에는 그레들을 사용해 프로젝트를 빌드 이전 상태로 돌리고 다시 빌드하는 명령어를 실행합니다. | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: make application-mysql.yml | |
run: | | |
cd ./TWO/src/main/resources | |
echo "${{ secrets.MYSQL_APPLICATION }}" >> ./application.properties | |
- run: cat ./TWO/src/main/resources/application.properties | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
working-directory: TWO | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
working-directory: TWO | |
# github artifact에 jar파일 복사 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-artifact | |
path: build/libs/*.jar | |
- name: Copy jar file to remote | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: "./TWO/build/libs/*.jar" | |
target: "/home/ubuntu/cicd" | |
strip_components: 2 | |
- name: Copy deploy script file to remote | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: "deploy.sh" | |
target: "/home/ubuntu/cicd" | |
- name: Execute deploy script | |
uses: appleboy/ssh-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script_stop: true | |
script: | | |
chmod +x /home/ubuntu/cicd/deploy.sh | |
sh /home/ubuntu/cicd/deploy.sh |