update packages #53
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
name: Deploy to server | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main # Trigger this workflow on push to the main branch | |
env: | |
SERVER_HOST: ${{ secrets.ip_host }} | |
SERVER_USERNAME: ubuntu | |
SERVER_KEY: ${{ secrets.secret_key_name }} | |
FOLDER_NAME: FelicityBot-v2 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: yarn install | |
- name: Build app | |
run: yarn build | |
- name: Copy dist directory to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ env.SERVER_HOST }} | |
username: ${{ env.SERVER_USERNAME }} | |
key: ${{ env.SERVER_KEY }} | |
source: "*" | |
target: "~/${{ env.FOLDER_NAME }}" | |
rm: true | |
# It needs to use root to copy this file | |
# - name: Copy service config file to systemd | |
# uses: appleboy/scp-action@master | |
# with: | |
# host: ${{ env.SERVER_HOST }} | |
# username: ${{ env.SERVER_USERNAME }} | |
# key: ${{ env.SERVER_KEY }} | |
# source: "felicity.service" | |
# target: "/etc/systemd/system/" | |
# overwrite: true | |
- name: Copy .env to app folder | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.SERVER_HOST }} | |
username: ${{ env.SERVER_USERNAME }} | |
key: ${{ env.SERVER_KEY }} | |
script: cp ~/.env ~/${{ env.FOLDER_NAME }}/.env | |
- name: Reload systemd files | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.SERVER_HOST }} | |
username: ${{ env.SERVER_USERNAME }} | |
key: ${{ env.SERVER_KEY }} | |
script: sudo systemctl daemon-reload | |
- name: Restart app | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.SERVER_HOST }} | |
username: ${{ env.SERVER_USERNAME }} | |
key: ${{ env.SERVER_KEY }} | |
script: sudo systemctl restart felicity && sudo systemctl status felicity |