-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (182 loc) · 7.53 KB
/
action.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: "Plugin Check and Release"
on:
push:
branches:
- main
workflow_dispatch:
inputs:
wp_version:
description: "WordPress version to test against"
required: true
default: "6.6.2"
plugin_version:
description: "Plugin version to release"
required: true
default: "1.0.0"
env:
PLUGIN_SLUG: "wpoven-performance-logs"
WP_PATH: /var/www/html
PLUGIN_PATH: /var/www/html/wp-content/plugins/wpoven_perflogs
WORDPRESS_URL: http://localhost
ADMIN_USER: admin
ADMIN_PASSWORD: Wpoven@baseapp1
ADMIN_EMAIL: [email protected]
jobs:
plugin-check:
name: WordPress Plugin Check
runs-on: ubuntu-latest
outputs:
status: ${{ steps.plugin-check.outputs.status }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
extensions: mbstring, xml, mysql
coverage: none
- name: Verify PHP installation
run: php -v
- name: Start MySQL
run: |
sudo systemctl start mysql
mysql -e "CREATE DATABASE IF NOT EXISTS wordpress_test;" -uroot -proot
- name: Setup WordPress
run: |
# Download and extract WordPress
wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www/html --strip-components=1
# Configure wp-config.php
sudo cp $WP_PATH/wp-config-sample.php $WP_PATH/wp-config.php
sudo sed -i 's/database_name_here/wordpress_test/' $WP_PATH/wp-config.php
sudo sed -i 's/username_here/root/' $WP_PATH/wp-config.php
sudo sed -i 's/password_here/root/' $WP_PATH/wp-config.php
# Set permissions
sudo chown -R www-data:www-data $WP_PATH
sudo chmod -R 755 $WP_PATH
sudo service apache2 start
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
- name: Install WordPress Core
run: |
cd $WP_PATH
wp core install \
--url="$WORDPRESS_URL" \
--title="Test Site" \
--admin_user="$ADMIN_USER" \
--admin_password="$ADMIN_PASSWORD" \
--admin_email="$ADMIN_EMAIL" \
--skip-email
- name: Setup Plugin
run: |
sudo mkdir -p $PLUGIN_PATH
# Clone the repository into a temporary directory
TEMP_DIR=$(mktemp -d)
git clone https://github.com/baseapp/wpoven_perflogs.git $TEMP_DIR
cd $TEMP_DIR
git submodule init
git submodule sync
git submodule update --init --recursive --force
# Move the contents of the source folder to the plugin path
sudo cp -r $TEMP_DIR/source/* $PLUGIN_PATH/
sudo chown -R www-data:www-data $PLUGIN_PATH
# Clean up the temporary directory
rm -rf $TEMP_DIR
- name: Activate and Verify Plugin
id: plugin-check
run: |
cd $WP_PATH
wp plugin activate wpoven_perflogs
wp plugin verify-checksums wpoven_perflogs
echo "status=success" >> $GITHUB_OUTPUT
- name: Run Plugin Check
uses: wordpress/plugin-check-action@v1
with:
exclude-checks: |
i18n_usage
late_escaping
exclude-files: |
.gitignore
.gitmodules
exclude-directories: |
includes/libraries/redux-framework
includes/libraries/plugin-update-checker
env:
PLUGIN_DIR: ${{ env.PLUGIN_PATH }}
PLUGIN_SLUG: ${{ env.PLUGIN_SLUG }}
WP_VERSION: ${{ github.event.inputs.wp_version || 'latest' }}
- name: Verify Plugin Accessibility
run: |
SITE_URL="http://localhost"
PLUGIN_SETTINGS_PAGE="$SITE_URL/wp-admin/admin.php?page=wpoven-performance-logs"
MAIN_PAGE_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$SITE_URL")
SETTINGS_PAGE_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$PLUGIN_SETTINGS_PAGE")
if [ "$MAIN_PAGE_RESPONSE" != "200" ] || [ "$SETTINGS_PAGE_RESPONSE" != "200" ]; then
echo "Site accessibility check failed"
exit 1
fi
create-release:
name: Create Release
needs: plugin-check
if: needs.plugin-check.outputs.status == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set version variables
id: versions
run: |
RELEASE_DATE=$(date +'%Y-%m-%d')
PLUGIN_VERSION="${{ github.event.inputs.plugin_version || '1.0.0' }}"
ZIP_NAME="${{ env.PLUGIN_SLUG }}-${RELEASE_DATE}.zip"
echo "release_date=$RELEASE_DATE" >> $GITHUB_OUTPUT
echo "plugin_version=$PLUGIN_VERSION" >> $GITHUB_OUTPUT
echo "zip_name=$ZIP_NAME" >> $GITHUB_OUTPUT
- name: Create plugin package
run: |
# Create releases directory
mkdir -p releases
# Create plugin zip
(cd source && zip -r "../releases/${{ steps.versions.outputs.zip_name }}" . -x ".*" -x "__MACOSX" -x "*.git*")
# Create copy for GitHub release
cp "releases/${{ steps.versions.outputs.zip_name }}" "./${{ steps.versions.outputs.zip_name }}"
- name: Update README
run: |
sed -i "s/\*\*Tested up to:\*\* [0-9.]*/**Tested up to:** ${{ github.event.inputs.wp_version || '6.6.2' }}/" README.md
sed -i "s/\*\*Stable tag:\*\* [0-9.]*/**Stable tag:** ${{ steps.versions.outputs.plugin_version }}/" README.md
sed -i "s|/releases/download/[0-9.]*/wpoven-performance-logs-[0-9-]*.zip|/releases/download/${{ steps.versions.outputs.plugin_version }}/${{ steps.versions.outputs.zip_name }}|" README.md
# Update README.txt
sed -i "s/Tested up to: [0-9.]*/Tested up to: ${{ github.event.inputs.wp_version || '6.6.2' }}/" README.txt
sed -i "s/Stable tag: [0-9.]*/Stable tag: ${{ steps.versions.outputs.plugin_version }}/" README.txt
sed -i "s|/releases/download/[0-9.]*/wpoven-performance-logs-[0-9-]*.zip|/releases/download/${{ steps.versions.outputs.plugin_version }}/${{ steps.versions.outputs.zip_name }}|" README.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.versions.outputs.zip_name }}
tag_name: ${{ steps.versions.outputs.plugin_version }}
name: "WPOven Performance Logs v${{ steps.versions.outputs.plugin_version }}"
body: |
🚀 WPOven Performance Logs Release v${{ steps.versions.outputs.plugin_version }}
Release Date: ${{ steps.versions.outputs.release_date }}
Tested with WordPress: ${{ github.event.inputs.wp_version || '6.6.2' }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md README.txt releases/
git commit -m "Release v${{ steps.versions.outputs.plugin_version }} - Update README and add release files" || echo "No changes to commit"
git push