-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 6.35 KB
/
publish.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
135
136
name: Build and deploy wpssg site to GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: [$default-branch]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
on: workflow_dispatch
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Prerequisites
run: |
sudo apt install php-cli php-mysql php-dom mysql-server sqlite3
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
curl -o composer.phar https://getcomposer.org/installer
curl -O -L https://github.com/elementor/wp2static/archive/refs/tags/7.2.tar.gz
git clone https://github.com/dirtsimple/postmark
git clone https://github.com/mysql2sqlite/mysql2sqlite
- name: Setup WordPress
run: |
sudo service mysql start
sudo mysql -h 127.0.0.1 --user=root --password=root <<< "CREATE USER 'wpssguser'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'wpssgpass'; CREATE DATABASE wpssgdb; GRANT ALL PRIVILEGES ON wpssgdb.* TO 'wpssguser'@'127.0.0.1';"
sudo mysql -h 127.0.0.1 --user=wpssguser --password=wpssgpass <<< "SHOW DATABASES"
php ./wp-cli.phar core download --locale=en_US #--skip-content --force
php ./wp-cli.phar config create --locale=en_US --dbuser=wpssguser --dbpass=wpssgpass --dbname=wpssgdb --dbhost=127.0.0.1
#php ./wp-cli.phar db create
php ./wp-cli.phar core install --url=localhost:8080 --title=wpcli --admin_user=wpcli --admin_password=wpcli [email protected]
php ./wp-cli.phar option set permalink_structure '/%year%-%monthnum%-%day%-%postname%/'
#php ./wp-cli.phar theme install --activate https://knd.te-st.ru/kandinsky.zip
- name: Setup postmark
run: |
cp postmark_composer.json postmark/composer.json
sed -i 's@League\\CommonMark\\Ext\\Table\\TableExtension@dirtsimple\\Postmark\\ShortcodeParser@g' ./postmark/src/Formatter.php
sed -i 's@League\\CommonMark\\Ext\\Strikethrough\\StrikethroughExtension@dirtsimple\\Postmark\\ShortcodeParser@g' ./postmark/src/Formatter.php
sed -i 's@League\\CommonMark\\Ext\\SmartPunct\\SmartPunctExtension@dirtsimple\\Postmark\\ShortcodeParser@g' ./postmark/src/Formatter.php
sed -i 's@Webuni\\CommonMark\\AttributesExtension\\AttributesExtension@dirtsimple\\Postmark\\ShortcodeParser@g' ./postmark/src/Formatter.php
php ./wp-cli.phar package install ./postmark
sed -i 's@WP_CLI\\Entity\\RecursiveDataStructureTraverser@WP_CLI\\Traverser\\RecursiveDataStructureTraverser@' ~/.wp-cli/packages/vendor/dirtsimple/imposer/src/Scheduler.php
sed -i 's@WP_CLI\\Entity\\NonExistentKeyException@WP_CLI\\Exception\\NonExistentKeyException@' ~/.wp-cli/packages/vendor/dirtsimple/imposer/src/Scheduler.php
#php ./wp-cli.phar post delete $(php ./wp-cli.phar post list --post_type='post' --format=ids) --force
php ./wp-cli.phar postmark tree _posts
echo ListPage && php ./wp-cli.phar post list --post_type=page --field=url
echo ListPost && php ./wp-cli.phar post list --post_type=post --field=url
php ./wp-cli.phar export --filename_format=exportWXR.xml
- name: Export to Sqlite
run: |
sudo mysqldump -h 127.0.0.1 --user=wpssguser --password=wpssgpass --skip-extended-insert --no-tablespaces --xml --no-create-info --compact wpssgdb wp_options --result-file=wpssgopts.xml
sudo mysqldump -h 127.0.0.1 --user=wpssguser --password=wpssgpass --skip-extended-insert --no-tablespaces --no-data --compact wpssgdb --result-file=wpssgddl.sql
sudo mysqldump -h 127.0.0.1 --user=wpssguser --password=wpssgpass --skip-extended-insert --no-tablespaces --no-create-info --compact wpssgdb --result-file=wpssgdata.sql && sed -e "s/\\\'/''/g" -e "s/_binary //g" wpssgdata.sql > wpssgdatasqlite.sql
awk -f mysql2sqlite/mysql2sqlite wpssgddl.sql | sed s'/PRAGMA journal_mode = MEMORY/PRAGMA journal_mode = DELETE/' > wpssgddlsqlite.sql
sqlite3 wpssgsqlite.db < wpssgddlsqlite.sql
sqlite3 wpssgsqlite.db < wpssgdatasqlite.sql
- name: Setup wp2static
run: |
mkdir -p ./wp-content/plugins/wp2static # php wp-cli.phar plugin path
tar -xf 7.2.tar.gz -C ./wp-content/plugins/wp2static --strip-components=1
cd ./wp-content/plugins/wp2static
mv ../../../composer.phar .
php composer.phar install
php composer.phar update
php composer.phar build
php composer.phar install --quiet --no-dev --optimize-autoloader
cd ../../../
php ./wp-cli.phar plugin activate wp2static
php ./wp-cli.phar wp2static options set deploymentURL http://localhost:8080/
- name: Run wp2static
run: |
php ./wp-cli.phar server --host=localhost --port=8080 &
sleep 5
php ./wp-cli.phar wp2static detect
php ./wp-cli.phar wp2static crawl
php ./wp-cli.phar wp2static post_process
mv ./wp-content/uploads/wp2static-processed-site _site
- name: Artifacts
uses: actions/upload-artifact@v4
with:
path: |
exportWXR.xml
wpssgopts.xml
wpssgddl.sql
wpssgdata.sql
wpssgddlsqlite.sql
wpssgdatasqlite.sql
wpssgsqlite.db
_site/
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v4
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4