Skip to content

Merge pull request #450 from GroupProject-JOM/dev #2

Merge pull request #450 from GroupProject-JOM/dev

Merge pull request #450 from GroupProject-JOM/dev #2

Workflow file for this run

name: BuildDeploy
on:
push:
branches:
- deployment
jobs:
build:
runs-on: ubuntu-latest
name: Build and Deploy
steps:
- name: Set env vars (common)
run: |
echo "REMOTE_HOST="${{ secrets.SSH_HOST }} >> $GITHUB_ENV
echo "REMOTE_APP_FOLDER=/var/www/html/Frontend-web-" >> $GITHUB_ENV
- name: Compress Files
run: |
touch build.tar.gz
tar --exclude=build.tar.gz -zcvf build.tar.gz ./.
- name: Copy build to server
uses: nogsantos/scp-deploy@master
with:
src: ./build.tar.gz
host: ${{ env.REMOTE_HOST }}
remote: ${{ env.REMOTE_APP_FOLDER }}
port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
- name: SSH Decompress
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ env.REMOTE_APP_FOLDER }}
tar xvzf ./build.tar.gz --directory ./
rm ./build.tar.gz
- name: SSH Start/Restart Application
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ env.REMOTE_APP_FOLDER }}
sudo systemctl reload nginx