This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
temp #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: ssh for dev deploy | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "master" branch | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# Runs a single command using the runners shell | |
- name: SSH Remote Commands | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.USER_NAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
# ssh 연결이 아무리 늦어도 20초 정도면 된다. | |
# 이 이상 끌게되면 사실상 접속 실패이므로 40초 타임아웃을 걸어두자 | |
timeout: 40s | |
script: | | |
echo "#START" | |
sudo apt update && sudo apt-get -y upgrade | |
cd /root/REST_API_Server | |
echo "############# GIT PULL #############" | |
pass=$(sudo git pull origin master) | |
echo $pass | |
if [ -n "$pass" ]; then | |
echo "############# Install dependent #############" | |
sudo pip install -r requirements.txt | |
echo "############# Server Stop #############" | |
sudo fuser -k 80/tcp | |
echo "############# Server Start #############" | |
sudo python3 main.py | |
else | |
echo "############## git pull: Error ##############" | |
exit 1; | |
fi |