-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (95 loc) · 4.76 KB
/
develop.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Deploy Laravel to Develop
on:
push:
branches:
- develop
jobs:
deploy-artifact:
name: Deploy artifact
runs-on: ubuntu-latest
steps:
- name: Get last repository version
uses: actions/checkout@v2
- name: Compile CSS and Javascript
run: |
npm install
npm run build
- name: Configure PHP 8.2
uses: shivammathur/setup-php@master
with:
php-version: 8.2
extensions: mbstring, ctype, fileinfo, openssl, PDO, bcmath, json, tokenizer, xml
- name: Composer install
run: composer install --no-interaction --prefer-dist --ignore-platform-reqs
- name: Create deployment artifact
env:
GITHUB_SHA: ${{ github.sha }}
run: tar -czf "${GITHUB_SHA}".tar.gz --exclude=*.git --exclude=node_modules *
- name: Upload to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: ${{ github.sha }}.tar.gz
target: /tmp/artifacts
# source: "phpdocxconfig.ini"
#target: /var/www/html/vendor/phpdocx/config/
- name: Extract files and create directories
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
LARAVEL_ENV: ${{ vars.LARAVEL_ENV_DEV }}
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: "phpdocxconfig.ini"
target: /var/www/html/dev/backend/
envs: GITHUB_SHA, SERVER_PASSWORD, LARAVEL_ENV
script: |
# Create a new directory
echo ${SERVER_PASSWORD} | sudo -S mkdir -p "${{ secrets.DEPLOY_PATH }}/dev/backend"
# Extract the tar file into the release directory
echo ${SERVER_PASSWORD} | sudo -S tar xzf /tmp/artifacts/${GITHUB_SHA}.tar.gz -C "${{ secrets.DEPLOY_PATH }}/dev/backend"
echo ${SERVER_PASSWORD} | sudo -S touch ${{ secrets.DEPLOY_PATH }}/dev/backend/.env
echo ${SERVER_PASSWORD} | sudo -S chown root.www-data ${{ secrets.DEPLOY_PATH }}/dev/backend/.env
echo ${SERVER_PASSWORD} | sudo -S chmod 0777 ${{ secrets.DEPLOY_PATH }}/dev/backend/.env
echo ${SERVER_PASSWORD} | sudo -S echo "${LARAVEL_ENV}" > "${{ secrets.DEPLOY_PATH }}/dev/backend/.env"
# Create Laravel storage directories and set permissions
echo ${SERVER_PASSWORD} | sudo -S mkdir -p ${{ secrets.DEPLOY_PATH }}/dev/backend/storage/{app,public,framework,logs,clockwork}
echo ${SERVER_PASSWORD} | sudo -S mkdir -p ${{ secrets.DEPLOY_PATH }}/dev/backend/storage/framework/{cache,sessions,testing,views}
echo ${SERVER_PASSWORD} | sudo -S mkdir -p ${{ secrets.DEPLOY_PATH }}/dev/backend/storage/framework/cache/data
echo ${SERVER_PASSWORD} | sudo -S mkdir -p ${{ secrets.DEPLOY_PATH }}/dev/backend/storage/app/public
echo ${SERVER_PASSWORD} | sudo -S mkdir -p ${{ secrets.DEPLOY_PATH }}/dev/backend/storage/app/public/uploads
# Set permissions to folder
echo ${SERVER_PASSWORD} | sudo -S chown -R root.www-data "${{ secrets.DEPLOY_PATH }}/dev/backend/"
echo ${SERVER_PASSWORD} | sudo -S chmod -R 0777 ${{ secrets.DEPLOY_PATH }}/dev/backend/storage
- name: Run migrations and clean cache
uses: appleboy/ssh-action@master
env:
GITHUB_SHA: ${{ github.sha }}
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
envs: GITHUB_SHA, SERVER_PASSWORD
script: |
# Run migrations and clean cache
cd "${{ secrets.DEPLOY_PATH }}/dev/backend"
echo ${SERVER_PASSWORD} | sudo -S php artisan passport:keys
echo ${SERVER_PASSWORD} | sudo -S php artisan storage:link
echo ${SERVER_PASSWORD} | sudo -S php artisan vendor:publish --tag=laravel-assets --ansi --force
echo ${SERVER_PASSWORD} | sudo -S php artisan config:clear
echo ${SERVER_PASSWORD} | sudo -S php artisan optimize
echo ${SERVER_PASSWORD} | sudo -S php artisan migrate
echo ${SERVER_PASSWORD} | sudo -S supervisorctl restart all
#Run clean up
rm -rf /tmp/artifacts
#Run clean up
rm -rf /tmp/artifacts