File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed
Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Test e2e Deploy to WP Engine
2+ on :
3+ push :
4+ branches :
5+ - main
6+ pull_request :
7+ branches :
8+ - main
9+
10+
11+ jobs :
12+ run_action :
13+ runs-on : ubuntu-latest
14+ outputs :
15+ status : ${{ steps.deploy.outputs.status }}
16+ steps :
17+ - uses : actions/checkout@v3
18+ - name : Bump test plugin version number
19+ run : sed -i 's/0.0.1/0.0.2/' tests/data/plugins/test-plugin/test-plugin.php
20+ - name : GitHub Action Deploy to WP Engine
21+ id : deploy
22+ uses : ./
23+ with :
24+ # Deploy vars
25+ WPE_SSHG_KEY_PRIVATE : ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
26+ WPE_ENV : ghae2e
27+ # Deploy Options
28+ SRC_PATH : " tests/data/plugins/test-plugin"
29+ REMOTE_PATH : " wp-content/plugins/"
30+ PHP_LINT : TRUE
31+ FLAGS : -r --backup --backup-dir=/tmp --itemize-changes
32+ SCRIPT : " tests/data/post-deploy/test-plugin.sh"
33+ CACHE_CLEAR : TRUE
34+ validate_result :
35+ runs-on : ubuntu-latest
36+ needs : run_action
37+ steps :
38+ - name : Validate deploy results
39+ run : |
40+ [ ${{needs.run_action.outputs.status}} = "pass" ] || exit 1
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Plugin Name: Deploy WordPress to WP Engine - e2e Test
4+ * Plugin URI: https://github.com/wpengine/github-action-wpe-site-deploy
5+ * Description: Sample code to test the Site Deployment GitHub Action by WP Engine.
6+ * Version: 0.0.1
7+ */
8+
9+ add_action ('init ' , 'register_my_cpt ' );
10+
11+ function register_my_cpt () {
12+ register_post_type ('my-cpt ' , array (
13+ 'public ' => true
14+ ));
15+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ BACKUP_DIR=/tmp
4+ PLUGINS_DIR=wp-content/plugins
5+ PLUGIN_NAME=test-plugin
6+
7+ cleanup () {
8+ rm tests/data/post-deploy/test-plugin.sh
9+ }
10+ trap cleanup EXIT
11+
12+ # Get the the new plugin version
13+ AFTER_PLUGIN_VERSION=$( wp plugin get $PLUGIN_NAME | sed -n " /version/p" | cut -f2)
14+ echo " New test plugin version: $AFTER_PLUGIN_VERSION "
15+
16+ # Revert to backup created by rsync if it exists
17+ if [ -d $BACKUP_DIR /$PLUGIN_NAME ]; then
18+ rm -rf $PLUGINS_DIR /$PLUGIN_NAME && mv $BACKUP_DIR /$PLUGIN_NAME $PLUGINS_DIR /
19+ fi
20+
21+ # Get the old plugin version
22+ BEFORE_PLUGIN_VERSION=$( wp plugin get $PLUGIN_NAME | sed -n " /version/p" | cut -f2)
23+ echo " Old test plugin version: $BEFORE_PLUGIN_VERSION "
24+
25+ # Check that the expected update was made
26+ if [ -z " $BEFORE_PLUGIN_VERSION " ] || [ -z " $AFTER_PLUGIN_VERSION " ] || [ " $BEFORE_PLUGIN_VERSION " = " $AFTER_PLUGIN_VERSION " ]; then
27+ echo " Failure: Test plugin was not updated!"
28+ echo " ::set-output name=status::fail"
29+ else
30+ echo " Success: Test plugin successfully updated from $BEFORE_PLUGIN_VERSION to $AFTER_PLUGIN_VERSION !"
31+ echo " ::set-output name=status::pass"
32+ fi
You can’t perform that action at this time.
0 commit comments