1+ name : GameStore Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - dev
7+ release :
8+ types : [published]
9+
10+ jobs :
11+ deploy :
12+ runs-on : ubuntu-latest
13+ env :
14+ TARGET_PATH : ${{ github.eventname == 'push' && secrets.SERVER_DEV_TARGET_PATH || secrets.SERVER_PROD_TARGET_PATH }}
15+
16+ steps :
17+ - name : Checkout
18+ uses : actions/checkout@master
19+
20+ - name : Prepare WordPress Zip
21+ run : |
22+ WP_LINK=$(cat wp-version-control.cfg)
23+ wget -O "./wordpress.zip" $WP_LINK
24+
25+ - name : Prepare plugins and themes
26+ run : zip -r wpcontent.zip plugins mu-plugins themes
27+
28+ - name : Copy Zips to Server
29+ uses : appleboy/scp-action@master
30+ with :
31+ host : ${{ secrets.SERVER_HOST }}
32+ username : ${{ secrets.SERVER_USER }}
33+ password : ${{ secrets.SERVER_SSH_PASSWORD }}
34+ port : ${{ secrets.SERVER_PORT }}
35+ source : " wordpress.zip,wpcontent.zip"
36+ target : ${{ env.TARGET_PATH }}
37+ - name : Maintenance On # Это нужно чтобы не сломать сайт на время деплоя
38+ uses : appleboy/scp-action@master
39+ with :
40+ host : ${{ secrets.SERVER_HOST }}
41+ username : ${{ secrets.SERVER_USER }}
42+ password : ${{ secrets.SERVER_SSH_PASSWORD }}
43+ port : ${{ secrets.SERVER_PORT }}
44+ source : " .maintenance"
45+ target : ${{ env.TARGET_PATH }}
46+ - name : Update WordPress Core
47+ uses : appleboy/scp-action@master
48+ with :
49+ host : ${{ secrets.SERVER_HOST }}
50+ username : ${{ secrets.SERVER_USER }}
51+ password : ${{ secrets.SERVER_SSH_PASSWORD }}
52+ port : ${{ secrets.SERVER_PORT }}
53+ script : |
54+ find "${{ env.TARGET_PATH }}" -type f -name "*.php ! -name "wp-config.php" -delete;
55+ rm -r "${{ env.TARGET_PATH }}/wp-admin" "${{ env.TARGET_PATH }}/wp-includes";
56+ unzip -o "${{ env.TARGET_PATH }}/wordpress.zip" -d "${{ env.TARGET_PATH }}/";
57+ mv "${{ env.TARGET_PATH }}/wordpress/*" "${{ env.TARGET_PATH }}/";
58+ rm -r "${{ env.TARGET_PATH }}/wordpress";
59+ - name : Update Plugins and Themes
60+ uses : appleboy/ssh-action@v1.0.3
61+ with :
62+ host : ${{ secrets.SERVER_HOST }}
63+ username : ${{ secrets.SERVER_USER }}
64+ password : ${{ secrets.SERVER_SSH_PASSWORD }}
65+ port : ${{ secrets.SERVER_PORT }}
66+ script : |
67+ rm -rf "${{ env.TARGET_PATH }}/wp-content/plugins" "${{ env.TARGET_PATH }}/wp-content/mu-plugins" "${{ env.TARGET_PATH }}/wp-content/themes";
68+ unzip -o "${{ env.TARGET_PATH }}/wpcontent.zip" -d "${{ env.TARGET_PATH }}/wp-content/";
69+ - name : Disable Maintenance Mode and Remove zips
70+ uses : appleboy/ssh-action@v1.0.3
71+ with :
72+ host : ${{ secrets.SERVER_HOST }}
73+ username : ${{ secrets.SERVER_USER }}
74+ password : ${{ secrets.SERVER_SSH_PASSWORD }}
75+ port : ${{ secrets.SERVER_PORT }}
76+ script : |
77+ rm -f "${{ env.TARGET_PATH }}/.maintenance";
78+ rm -f "${{ env.TARGET_PATH }}/wordpress.zip";
79+ rm -f "${{ env.TARGET_PATH }}/wpcontent.zip";
0 commit comments