Skip to content

chore : prod cicd 파이프라인 구축 (#127) #2

chore : prod cicd 파이프라인 구축 (#127)

chore : prod cicd 파이프라인 구축 (#127) #2

name: Prod CI/CD
on:
push:
branches: [prod]
permissions:
contents: read
jobs:
build:
runs-on: dev
permissions:
pull-requests: write
steps:
- name: 레포지토리 체크아웃
uses: actions/[email protected]
with:
fetch-depth: 3
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: true
- run: git log --pretty=oneline
- name: JDK 21을 설치합니다.
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
- name: gradlew 권한을 부여합니다.
run: chmod +x gradlew
- name: Gradle을 통해 빌드합니다.
run: ./gradlew build
- name: 빌드 파일 deploy 파일로 이동
run: cp -f build/libs/*.jar /home/ubuntu/deploy/
- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push to DockerHub
run: |
docker build --tag ${{secrets.DOCKER_USERNAME}}/${{secrets.DOCKER_USERNAME}} .
docker push ${{secrets.DOCKER_USERNAME}}/${{secrets.DOCKER_USERNAME}}:latest
- name: Deploy to prod server
uses: appleboy/ssh-action@master
with:
host: ${{secrets.PROD_SERVER}}
username: ${{secrets.PROD_USER_NAME}}
key: ${{secrets.PROD_PEM_KEY}}
script: |
cd ~/deploy
sh deploy.sh