Skip to content

applied github actions #23

applied github actions

applied github actions #23

Workflow file for this run

name: testAndDeploy
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Java setup
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run test
run: ./gradlew test
- name: test build
run: ./gradlew build -x test
deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Set up known hosts
run: |
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: SSH and deploy
uses: appleboy/ssh-action@master
env:
APPLICATION_YML: ${{ secrets.APPLICATION_YML }}
with:
host: ${{ secrets.KIRBY_SERVER_HOST }}
username: ${{ secrets.KIRBY_SERVER_USERNAME }}
password: ${{ secrets.KIRBY_SERVER_PASSWORD }}
port: ${{ secrets.KIRBY_SERVER_PORT }}
script: |
cd old
cd unistMeal_backend
cd unistMeal-backend
git pull || exit 1
docker stop unist-meal-backend || exit 1
docker container rm unist-meal-backend || exit 1
docker build -t unist-meal-backend:latest . || exit 1
docker run -d --name unist-meal-backend --net host -e TZ=Asia/Seoul -e secretKey=${{ secrets.SECRET_KEY }} unist-meal-backend:latest || exit 1
exit