-
Notifications
You must be signed in to change notification settings - Fork 7
124 lines (109 loc) · 3.74 KB
/
main.yml
File metadata and controls
124 lines (109 loc) · 3.74 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Daskomlab.com deployment
on:
pull_request:
branches: [ master ]
types: [ closed ]
jobs:
build_composer:
if: github.event.pull_request.merged == true
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Determine Composer cache directory
shell: bash
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
- name: Cache dependencies installed with Composer
uses: actions/cache@v2
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: os-${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
- name: Install composer dependencies
uses: php-actions/composer@v5
with:
php_version: 7.4
version: 1
- name: Zip composer install result
shell: bash
run: |
zip -r build_composer.zip vendor composer.lock
- name: Upload composer install result
uses: actions/upload-artifact@v2
with:
name: build_composer_result
path: build_composer.zip
build_nodejs:
needs: build_composer
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Download composer install result
uses: actions/download-artifact@v2
with:
name: build_composer_result
- name: Unzip composer install result
shell: bash
run: |
unzip -o build_composer.zip
rm build_composer.zip
- name: Download production env
shell: bash
run: wget ${{ secrets.ENV_GIST }} -O .env
- name: Change socket.io port
shell: bash
run: sed -i 's/:6001//g' ./resources/js/app.js
- name: Install nodejs dependencies
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
- run: npm run prod
- name: Commit changes and zip the folder
shell: bash
run: |
zip -r daskomweb_build.zip .
- name: Upload all build result to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
source: "daskomweb_build.zip"
target: "~/"
deploy:
needs: [build_composer, build_nodejs]
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Connecting and Deploying to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.PORT }}
script: |
echo ${{ secrets.ROOT_PASSWORD }} | sudo -S sudo rm -rf ${{ secrets.PROJECT_PATH_TEMP }}
mkdir ${{ secrets.PROJECT_PATH_TEMP }}
cd ${{ secrets.PROJECT_PATH_TEMP }}
mv ~/daskomweb_build.zip ./ && unzip daskomweb_build.zip && rm daskomweb_build.zip
#
##
### Setting up build folder for the project
##
#
echo ${{ secrets.ROOT_PASSWORD }} | sudo -S sudo chmod +777 -R storage
cp ~/entrypoint-scripts/laravel-echo-server.json .
cp ~/entrypoint-scripts/runEcho.sh .
#
##
### Deploy them allllll
##
#
cd ~/
echo ${{ secrets.ROOT_PASSWORD }} | sudo -S sudo rm -rf ${{ secrets.PROJECT_PATH }}
mv ${{ secrets.PROJECT_PATH_TEMP }} ${{ secrets.PROJECT_PATH }}
cd ${{ secrets.PROJECT_PATH }}
pm2 delete all
pm2 start runEcho.sh
php artisan up