Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh -e

# Deploys to the production server.

RELEASE_DIR="/home/public_html/site/releases/"
RSYNC_DIR="/home/public_html/site/latest/"
USERGUIDE_DIR="/home/public_html/userguides"
CONFIG_FILE="/home/public_html/config/.env.site"

cd ~/
RELEASE=`date +"%d-%m-%Y-%H-%M-%S"`

echo $'Copy current release\n'
cd $RELEASE_DIR
cp -r ../latest ./$RELEASE

echo $'Install composer dependencies\n'
cd $RELEASE_DIR/$RELEASE
composer install --no-dev

echo $'Setup FS\n'
cd $RELEASE_DIR/$RELEASE
sudo chmod -R 777 writable
sudo chmod -R a+rx vendor
sudo ln -nsf $CONFIG_FILE .env

echo $'Link current user guide\n'
sudo ln -nsf $USERGUIDE_DIR/userguide4 public/user_guide

echo $'Set up Links\n'
cd $RELEASE_DIR
sudo ln -nsf $RELEASE_DIR/$RELEASE "../current"
sudo service php8.1-fpm reload
37 changes: 3 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}

- name: Deploy to Webserver
uses: yeshan333/rsync-deploy-action@main
uses: yeshan333/rsync-deploy-action@v1
id: rsync-deploy-action
with:
ssh_login_username: ${{ secrets.DEPLOY_USER }}
Expand All @@ -32,40 +32,9 @@ jobs:
destination_path: "/home/public_html/site/latest"

- name: Finalize deployment
uses: appleboy/ssh-action@master
env:
RELEASE_DIR: "/home/public_html/site/releases/"
RSYNC_DIR: "/home/public_html/site/latest/"
USERGUIDE_DIR: "/home/public_html/userguides"
CONFIG_FILE: "/home/public_html/config/.env.site"
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_SSH_BOX }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
script_stop: true
envs: RELEASE_DIR,CONFIG_FILE,RSYNC_DIR,USERGUIDE_DIR
script: |
cd ~/
RELEASE=`date +"%d-%m-%Y-%H-%M-%S"`

echo $'Copy current release\n'
cd $RELEASE_DIR
cp -r ../latest ./$RELEASE

echo $'Install composer dependencies\n'
cd $RELEASE_DIR/$RELEASE
composer install

echo $'Setup FS\n'
cd $RELEASE_DIR/$RELEASE
sudo chmod -R 777 writable
sudo chmod -R a+rx vendor
sudo ln -nsf $CONFIG_FILE .env

echo $'Link current user guide\n'
sudo ln -nsf $USERGUIDE_DIR/userguide4 public/user_guide

echo $'Set up Links\n'
cd $RELEASE_DIR
sudo ln -nsf $RELEASE_DIR/$RELEASE "../current"
sudo service php8.1-fpm reload
script: /home/public_html/site/latest/.github/scripts/deploy.sh