Skip to content

Commit ce6c736

Browse files
authored
First Commit
1 parent 597cdf2 commit ce6c736

File tree

11 files changed

+611
-0
lines changed

11 files changed

+611
-0
lines changed

.github/dependabot.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Dependabot configuration for automated dependency updates
2+
version: 2
3+
updates:
4+
# Updates for GitHub Actions used in workflows
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
day: "monday"
10+
time: "09:00"
11+
# Set custom labels on pull requests
12+
labels:
13+
- "dependencies"
14+
- "security"
15+
- "automated"
16+
# Limit the number of open PRs
17+
open-pull-requests-limit: 10
18+
# Assign reviewers automatically
19+
reviewers:
20+
- "EngineScript"
21+
# Create a group of updates for all actions
22+
groups:
23+
actions:
24+
patterns:
25+
- "*"
26+
27+
# Updates for npm packages
28+
- package-ecosystem: "npm"
29+
directory: "/"
30+
schedule:
31+
interval: "weekly"
32+
day: "wednesday"
33+
labels:
34+
- "dependencies"
35+
- "javascript"
36+
open-pull-requests-limit: 5
37+
reviewers:
38+
- "EngineScript"
39+
40+
# Updates for Composer packages
41+
- package-ecosystem: "composer"
42+
directory: "/"
43+
schedule:
44+
interval: "weekly"
45+
day: "friday"
46+
labels:
47+
- "dependencies"
48+
- "php"
49+
open-pull-requests-limit: 5
50+
reviewers:
51+
- "EngineScript"

.github/labeler.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Configuration for GitHub Actions Labeler
2+
# This file defines how automatic labels are applied to pull requests based on the files changed.
3+
# It helps categorize PRs by type of change (core functionality, frontend, documentation, etc.)
4+
# and makes it easier to identify what areas of the plugin are being modified.
5+
# The labels are applied automatically by the issue-management.yml workflow.
6+
7+
# Core plugin functionality
8+
core:
9+
- changed-files:
10+
- any-glob-to-any-file: simple-wp-optimizer.php
11+
- any-glob-to-any-file: includes/**/*
12+
- any-glob-to-any-file: assets/js/**/*
13+
14+
# Frontend related changes
15+
frontend:
16+
- changed-files:
17+
- any-glob-to-any-file: assets/css/**/*
18+
- any-glob-to-any-file: assets/images/**/*
19+
- any-glob-to-any-file: templates/**/*
20+
21+
# Workflows and automation
22+
automation:
23+
- changed-files:
24+
- any-glob-to-any-file: .github/**/*
25+
26+
# Security related changes
27+
security:
28+
- changed-files:
29+
- any-glob-to-any-file: '**/*.php'
30+
- any-glob-to-any-file: SECURITY.md
31+
32+
# Documentation
33+
documentation:
34+
- changed-files:
35+
- any-glob-to-any-file: README.md
36+
- any-glob-to-any-file: '*.md'
37+
- any-glob-to-any-file: docs/**/*
38+
39+
# Export functionality
40+
optimization:
41+
- changed-files:
42+
- any-glob-to-any-file: '**/optimi*.php'
43+
- any-glob-to-any-file: '**/cache*.php'
44+
- any-glob-to-any-file: '**/performance*.php'
45+
46+
# Database related changes
47+
database:
48+
- changed-files:
49+
- any-glob-to-any-file: '**/database*.php'
50+
- any-glob-to-any-file: '**/db*.php'
51+
- any-glob-to-any-file: '**/sql*.php'
52+
53+
# WordPress integration
54+
wordpress:
55+
- changed-files:
56+
- any-glob-to-any-file: '**/wp-*.php'
57+
- any-glob-to-any-file: '**/wordpress*.php'
58+
- any-glob-to-any-file: '**/admin*.php'
59+
60+
# Translations and localization
61+
i18n:
62+
- changed-files:
63+
- any-glob-to-any-file: languages/**/*
64+
- any-glob-to-any-file: '**/*.pot'
65+
- any-glob-to-any-file: '**/*.po'
66+
- any-glob-to-any-file: '**/*.mo'
67+
68+
# Dependencies
69+
dependencies:
70+
- changed-files:
71+
- any-glob-to-any-file: .github/dependabot.yml
72+
- any-glob-to-any-file: composer.json
73+
- any-glob-to-any-file: composer.lock
74+
- any-glob-to-any-file: package.json
75+
- any-glob-to-any-file: package-lock.json
76+
77+
# Tests and quality
78+
testing:
79+
- changed-files:
80+
- any-glob-to-any-file: tests/**/*
81+
- any-glob-to-any-file: phpunit.xml
82+
- any-glob-to-any-file: .travis.yml
83+
- any-glob-to-any-file: .phpcs.xml
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow automatically deletes the branch associated with a pull request
2+
# after it has been merged, unless the branch is protected (e.g., main, dev, staging).
3+
# It helps keep the repository clean by removing merged feature or bugfix branches.
4+
5+
name: Branch Cleanup
6+
7+
on:
8+
pull_request:
9+
types: [closed]
10+
11+
permissions:
12+
contents: write
13+
pull-requests: read
14+
15+
jobs:
16+
cleanup:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Delete merged branch
26+
if: github.event.pull_request.merged == true
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
30+
REPOSITORY: ${{ github.repository }}
31+
run: |
32+
echo "Checking branch: $BRANCH_NAME"
33+
34+
# Protected branch check - using quotes to prevent injection
35+
if [[ "$BRANCH_NAME" =~ ^(main|master|dev|develop|staging|production)$ ]]; then
36+
echo "::warning::Skipping deletion of protected branch: $BRANCH_NAME"
37+
exit 0
38+
fi
39+
40+
# Attempt branch deletion - using quotes to prevent injection
41+
echo "Attempting to delete branch: $BRANCH_NAME"
42+
if git push origin --delete "$BRANCH_NAME" 2>/dev/null; then
43+
echo "::notice::Successfully deleted branch: $BRANCH_NAME"
44+
else
45+
echo "::error::Failed to delete branch: $BRANCH_NAME"
46+
exit 1
47+
fi
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This workflow runs continuous integration checks on the Simple WP Optimizer plugin.
2+
# It performs code linting for both PHP and JavaScript files and builds the plugin package.
3+
# The workflow is triggered on push to main branch and on pull requests to ensure code quality.
4+
# It creates and stores a plugin zip file as an artifact that can be used for testing.
5+
6+
name: Continuous Integration
7+
8+
on:
9+
push:
10+
branches: [ main ]
11+
pull_request:
12+
branches: [ main ]
13+
14+
jobs:
15+
lint:
16+
name: Lint PHP and JavaScript
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.0'
26+
tools: composer:v2, phpcs
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '16'
32+
cache: 'npm'
33+
34+
- name: Install PHP dependencies
35+
run: composer install --prefer-dist --no-progress
36+
37+
- name: Install JS dependencies
38+
run: npm ci
39+
40+
- name: Lint PHP
41+
run: |
42+
if [ -f .phpcs.xml ] || [ -f phpcs.xml.dist ]; then
43+
composer run lint:php
44+
else
45+
echo "No PHP linting configuration found. Skipping."
46+
fi
47+
48+
- name: Lint JavaScript
49+
run: |
50+
if [ -f .eslintrc.js ] || [ -f .eslintrc.json ]; then
51+
npm run lint:js
52+
else
53+
echo "No JS linting configuration found. Skipping."
54+
fi
55+
56+
build:
57+
name: Build Plugin
58+
runs-on: ubuntu-latest
59+
needs: lint
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '16'
68+
cache: 'npm'
69+
70+
- name: Setup PHP
71+
uses: shivammathur/setup-php@v2
72+
with:
73+
php-version: '8.0'
74+
tools: composer:v2
75+
76+
- name: Install dependencies
77+
run: |
78+
composer install --no-dev --prefer-dist --no-progress
79+
npm ci
80+
81+
- name: Build frontend assets
82+
run: npm run build
83+
84+
- name: Create plugin package
85+
run: |
86+
mkdir -p build/simple-wp-optimizer
87+
cp -r assets includes languages templates simple-wp-optimizer.php readme.txt LICENSE build/simple-wp-optimizer/
88+
cd build
89+
zip -r simple-wp-optimizer.zip simple-wp-optimizer
90+
91+
- name: Upload build artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: simple-wp-optimizer
95+
path: build/simple-wp-optimizer.zip
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow automatically triages new and reopened issues and pull requests.
2+
# It applies labels using the labeler action and marks issues/PRs as stale after 30 days of inactivity,
3+
# closing them 7 days after being marked stale. This helps keep the issue tracker organized and up to date.
4+
5+
name: Issue Management
6+
7+
on:
8+
issues:
9+
types: [opened, reopened]
10+
pull_request:
11+
types: [opened, reopened]
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
issues: write
17+
18+
jobs:
19+
triage:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/labeler@v5
23+
with:
24+
repo-token: ${{ secrets.GITHUB_TOKEN }}
25+
configuration-path: .github/labeler.yml
26+
sync-labels: false
27+
- uses: actions/stale@v9
28+
with:
29+
days-before-stale: 30
30+
days-before-close: 7
31+
stale-issue-message: 'This issue is stale due to inactivity'
32+
stale-pr-message: 'This PR is stale due to inactivity'

.github/workflows/new-issue.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow automatically posts a guidance comment on new issues.
2+
# It provides instructions to help users submit detailed information about their
3+
# WordPress environment and the issue they're experiencing with the Simple WP Optimizer plugin.
4+
# This helps maintainers diagnose and fix issues more efficiently.
5+
6+
name: Issue Guidance
7+
8+
on:
9+
issues:
10+
types: [opened]
11+
12+
permissions:
13+
contents: write
14+
issues: write
15+
16+
jobs:
17+
guide:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Post guidance comment
21+
uses: peter-evans/create-or-update-comment@v4
22+
with:
23+
issue-number: ${{ github.event.issue.number }}
24+
body: |
25+
Thanks for opening an issue. Please provide a detailed description of the problem you're facing. If you have error messages or logs, please include them as well.
26+
27+
To help us diagnose the issue, please include:
28+
- WordPress version
29+
- PHP version
30+
- List of other plugins you're using
31+
- Steps to reproduce the issue
32+
- What you expected to happen vs. what actually happened
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow automatically posts a guidance comment on new pull requests.
2+
# It welcomes contributors and provides a brief message to acknowledge their
3+
# contribution to the Simple WP Optimizer plugin.
4+
# The workflow is triggered whenever a new pull request is opened.
5+
6+
name: New Pull Request Guidance
7+
8+
on:
9+
pull_request_target:
10+
types: [opened]
11+
12+
jobs:
13+
guide:
14+
runs-on: ubuntu-latest
15+
# Explicitly define permissions required by the job
16+
permissions:
17+
pull-requests: write
18+
steps:
19+
- name: Post guidance comment on new PR
20+
uses: peter-evans/create-or-update-comment@v4
21+
with:
22+
issue-number: ${{ github.event.pull_request.number }}
23+
body: |
24+
Thanks for contributing to Simple WP Optimizer! 🎉
25+
26+
27+
We'll review your PR soon!
28+
# Token is implicitly provided with the defined permissions
29+
# token: ${{ secrets.GITHUB_TOKEN }} # This line can be removed

0 commit comments

Comments
 (0)