Skip to content

Merge branch 'main' of https://github.com/Sam3Star/clock-server #4

Merge branch 'main' of https://github.com/Sam3Star/clock-server

Merge branch 'main' of https://github.com/Sam3Star/clock-server #4

Workflow file for this run

name: CI/CD using github actions & docker
on:
push:
branches: [ "main" ] # 해당 branch에 푸쉬 발생 시 업데이트
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: set chmod
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew bootJar
- name: Docker build & push to prod
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/clock .
docker push ${{ secrets.DOCKER_USERNAME }}/clock
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
with:
host: ${{ secrets.HOST_PROD }} # EC2 퍼블릭 IPv4 DNS
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }} # EC2 private key
port: ${{ secrets.PORT }} #ssh port (22)
envs: GITHUB_SHA
script: |
docker stop clock
docker rm clock
docker rmi ${{ secrets.DOCKER_USERNAME }}/clock
docker pull ${{ secrets.DOCKER_USERNAME }}/clock
docker run -d -p 8080:8080 --name welspy ${{ secrets.DOCKER_USERNAME }}/clock