Skip to content

Commit

Permalink
Create deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Buddhikanip authored Feb 29, 2024
1 parent 844460c commit ce95a05
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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

0 comments on commit ce95a05

Please sign in to comment.