-
Notifications
You must be signed in to change notification settings - Fork 24
71 lines (61 loc) · 2.16 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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