Skip to content

Merge pull request #424 from codeigniter4projects/develop #28

Merge pull request #424 from codeigniter4projects/develop

Merge pull request #424 from codeigniter4projects/develop #28

Workflow file for this run

name: "Deploy to Production"
on:
push:
branches: [master]
jobs:
deploy:
name: "Deploy to Production"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_KEY }}
name: id_rsa
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Deploy to Webserver
uses: yeshan333/rsync-deploy-action@main
id: rsync-deploy-action
with:
ssh_login_username: ${{ secrets.DEPLOY_USER }}
remote_server_ip: ${{ secrets.DEPLOY_SSH_BOX }}
ssh_port: ${{ secrets.DEPLOY_PORT }}
ssh_private_key: ${{ secrets.DEPLOY_KEY }}
source_path: "./*"
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"
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