Skip to content

Merge pull request #41 from SOPT-all/develop #3

Merge pull request #41 from SOPT-all/develop

Merge pull request #41 from SOPT-all/develop #3

Workflow file for this run

name: prod-CD
on:
push:
- main
jobs:
CI:
runs-on: ubuntu-22.04
environment: prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: create secret config file
run: |
cd src/main/resources
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml
- name: build with gradle
run: |
chmod +x gradlew
./gradlew clean build -x test
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.PROD_DOCKERHUB_USERNAME }}
password: ${{ secrets.PROD_DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile-prod
push: true
tags: ${{ secrets.PROD_DOCKERHUB_USERNAME }}/${{ secrets.PROD_REPONAME }}:latest
CD:
needs: [CI]
runs-on: ubuntu-22.04
environment: prod
steps:
- name: Docker Image Pull and Container Run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_SERVER_HOST }}
username: ${{ secrets.PROD_SERVER_USERNAME }}
key: ${{ secrets.PROD_SERVER_KEY }}
script: |
bash /home/ubuntu/35-APPJAM-SERVER-NAPZAKMARKET/deploy.sh