Skip to content

Commit a3e30de

Browse files
committed
ci: initial setup github actions
1 parent 48b2c44 commit a3e30de

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/CICD.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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";

.maintenance

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
$upgrading = time();
3+
?>

wp-version-control.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://wordpress.org/latest.zip

0 commit comments

Comments
 (0)