Skip to content

Workflow file for this run

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

Check failure on line 26 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

You have an error in your yaml syntax on line 26
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