Skip to content

Update README.md

Update README.md #19

Workflow file for this run

name: CI/CD using github actions & docker
on:
push:
branches: [ "main", "develop" ]
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
# JDK setting
- uses: actions/checkout@v3
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: recursive
# 서브 모듈 설정
- name: Update and Init Submodule
run: git submodule update --remote --recursive --init
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# gradle caching - 빌드 시간 향상
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# gradle build
- name: Build with Gradle
run: ./gradlew build -x test
- name: Separate Layered jar
run: java -Djarmode=layertools -jar build/libs/class-registration-1.0-SNAPSHOT.jar extract
# docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile.prod -t ${{ secrets.DOCKER_USERNAME }}/docker-team-b-prod .
docker push ${{ secrets.DOCKER_USERNAME }}/docker-team-b-prod
## deploy to production
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
if: contains(github.ref, 'main')
with:
host: ${{ secrets.HOST_PROD }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
ssh -i "${{ secrets.PEM_NAME }}" -o StrictHostKeyChecking=no ubuntu@${{ secrets.WAS_IP }} 'bash /home/ubuntu/deploy.sh'
ssh -i "${{ secrets.PEM_NAME }}" -o StrictHostKeyChecking=no ubuntu@${{ secrets.WAS2_IP }} 'bash /home/ubuntu/deploy.sh'