Skip to content

EDIT include -> require #60

EDIT include -> require

EDIT include -> require #60

Workflow file for this run

name: Deploy staging
on:
push:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Deploy staging from git
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
root_directory="/home/bitnami/htdocs-test"
repo_directory="$root_directory/repo"
release_directory="$root_directory/releases"
current_directory="$release_directory/$(date '+%Y%m%d%H%M%S')"
# Clone bare repository
[ -d $repo_directory ] || git clone --mirror --depth 1 https://github.com/pjshwa/apnee.git $repo_directory
# Make new release directory, and shared links
mkdir -p $current_directory
mkdir -p $root_directory/shared/static
# Keep only 5 recent releases
cd $release_directory
rm -rf `ls -t | tail -n +6`
# Clone materials into new release directory from git branch
cd $repo_directory
git fetch --depth 1 origin main
git archive main | /usr/bin/env tar -x -f - -C $current_directory
# Symlink shared materials
cd $current_directory
ln -sfn $root_directory/shared/static
# Fill credentials
echo "<?php \$credentials = array('host' => 'localhost', 'user' => '${{ secrets.DBUSER }}', 'pass' => '${{ secrets.DBPASS }}', 'database' => 'pjshwa_test'); ?>" | tee -a $current_directory/credentials.php
# Sync assets
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} aws s3 sync s3://pjshwa-homepage-assets/static ./static --delete
# Symlink current directory
cd $root_directory
ln -sfn $current_directory current
- name: Flush the PHP opcache
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: sudo /opt/bitnami/php/bin/cachetool opcache:reset --fcgi=/opt/bitnami/php/var/run/www.sock