Skip to content

fix

fix #2

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: CI/CD
on:
push:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Github secrets로부터 데이터를 받아서, 워크 플로우에 파일을 생성
- name: Make application.yaml
run: |
cd ./src/main/resources
touch ./application.yaml
echo "${{ secrets.PROPERTIES }}" > ./application.yaml
shell: bash
- name: Make application-openApi.yaml
run: |
cd ./src/main/resources
touch ./application-openApi.yaml
echo "${{ secrets.OPENAPI }}" > ./application-openApi.yaml
shell: bash
- name: Make application-jwt.yaml
run: |
cd ./src/main/resources
touch ./application-jwt.yaml
echo "${{ secrets.JWT }}" > ./application-jwt.yaml
shell: bash
- name: Make application-oauth.yaml
run: |
cd ./src/main/resources
touch ./application-oauth.yaml
echo "${{ secrets.OAUTH }}" > ./application-oauth.yaml
shell: bash
- name: Build with Gradle Wrapper
run: |
chmod +x gradlew
./gradlew build
## 도커허브 로그인
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
## 웹 이미지 빌드 및 도커허브에 push
- name: web docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest
## docker compose up
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{secrets.USERNAME}}
key: ${{ secrets.KEY }}
script: |
sudo docker rm -f $(docker ps -qa)
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
cd ~
sudo docker-compose up -d
sudo docker image prune -f