google.Analytics 주소 넣음 #97
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 with Gradle in main | |
# 동작 조건 설정 : main 브랜치에 push 혹은 pull request가 발생할 경우 동작한다. | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
# Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시하는 과정 | |
build-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
# 기본적인 체크아웃 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# 자바 버전 설정 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# gradlew에 실행 권한 부여 | |
- name: Executable to /gradlew | |
run: chmod +x ./gradlew | |
# 프로젝트 빌드 | |
- name: Project Build | |
run: ./gradlew clean bootwar | |
# 자바 Spring Boot 빌드 | |
# - name: Build with Gradle | |
# uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | |
# with: | |
# arguments: clean build | |
# 3. Docker 이미지 빌드 | |
- name: docker image build | |
run: docker build -t pswlove38/github-actions-demo . | |
# 4. DockerHub 로그인 | |
- name: docker login | |
uses: docker/login-action@v2 | |
with: | |
username: pswlove38 | |
password: a77981010! | |
# 5. Docker Hub 이미지 푸시 | |
- name: docker Hub push | |
run: docker push pswlove38/github-actions-demo | |
# 6. GCP에 SSH로 접속 | |
- name: executing remote ssh commands using ssh key | |
uses: appleboy/ssh-action@master | |
with: | |
host: 35.212.196.164 | |
username: pswlove38 | |
key: ${{ secrets.SSH }} | |
port: 22 | |
script: | | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull pswlove38/github-actions-demo | |
sudo docker pull pswlove38/change-nginx | |
docker-compose up -d | |
docker image prune -f |