-
Notifications
You must be signed in to change notification settings - Fork 18
134 lines (109 loc) · 4.26 KB
/
build-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
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
125
126
127
128
129
130
131
132
133
134
# .github/workflows/release.yml
name: Build and Deploy
on:
release:
types: [published]
env:
NODE_VERSION: 20
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: check theme version against tag
run: |
THEME_VERSION=$(cat sass/style.scss | grep Version | sed -r 's/version: +//I')
V="v"
echo Version in style.scss: $THEME_VERSION
if [ "$V$THEME_VERSION" != "${{ github.event.release.tag_name }}" ]; then exit 1; fi
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm packages
run: npm ci
- name: Build CSS
run: npm run compile:build
- name: Build CSS-RTL
run: npm run compile:rtl
- name: Build JS
run: npm run build
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- name: run install composer
run: |
composer install
cd lib && composer install
- name: Make bundle
run: npm run bundle
- name: fail on fork
if: github.repository_owner != 'verdigado'
run: exit 1
- name: Rename ZIP file
run: |
mv ../sunflower.zip sunflower-${{ github.event.release.tag_name }}.zip
- name: Upload Release
uses: ncipollo/release-action@v1
with:
artifacts: "sunflower-${{ github.event.release.tag_name }}.zip"
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Provide deploy_key
env:
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_USER: 'github-ci'
SSH_HOST: 'wordpress05.gcms.verdigado.net'
run: |
mkdir "$HOME/.ssh"
echo "$DEPLOY_KEY" > "$HOME/.ssh/production.key"
chmod 600 "$HOME/.ssh/production.key"
cat >> ~/.ssh/config <<END
Host production
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/production.key
StrictHostKeyChecking no
END
- name: save version
run: echo ${{ github.event.release.tag_name }} > version.txt
- name: rsync zipfile, version and changelog
env:
PAGEID: 1952
run: |
rsync -a sunflower-${{ github.event.release.tag_name }}.zip version.txt changelog.html production:/var/www/updateserver/
THEME_VERSION=$(cat version.txt | sed -e 's/^v//')
ssh production "cd /var/www && wp post get $PAGEID --field=content | sed -e 's/<version>[^<]*/<version>$THEME_VERSION/g' | sed -E 's/\/updateserver\/sunflower-v(.*)\.zip/\/updateserver\/sunflower-v$THEME_VERSION.zip/g' > /tmp/content-$PAGEID.txt"
ssh production "cd /var/www && wp post update $PAGEID - < /tmp/content-$PAGEID.txt && wp option update blogdescription 'Demoseite für das WordPress-Theme Sunflower $THEME_VERSION' --url=sunflower-theme.de/demo && wp option update blogname 'Sunflower $THEME_VERSION' && wp menu item update 147 --url=https://sunflower-theme.de/demo --link=https://sunflower-theme.de/updateserver/sunflower-v$THEME_VERSION.zip"
mkdocs:
runs-on: ubuntu-latest
needs: build-deploy
steps:
- uses: actions/checkout@v4
- name: mkdocs build
uses: Tiryoh/actions-mkdocs@v0
with:
mkdocs_version: 'latest' # option
# mkdocs_version: '1.1' # option
requirements: 'mkdocs/requirements.txt' # option
configfile: 'mkdocs/mkdocs.yml' # option
- name: Provide deploy_key
env:
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_USER: 'github-ci'
SSH_HOST: 'wordpress05.gcms.verdigado.net'
run: |
mkdir "$HOME/.ssh"
echo "$DEPLOY_KEY" > "$HOME/.ssh/production.key"
chmod 600 "$HOME/.ssh/production.key"
cat >> ~/.ssh/config <<END
Host production
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/production.key
StrictHostKeyChecking no
END
- name: save version
run: echo ${GITHUB_REF##*/} > version.txt
- name: rsync documentation
run: rsync -a --delete documentation/* production:/var/www/documentation/