Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update branch #52

Merged
merged 73 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
b72550b
Merge pull request #33 from nsquared-team/update-readme
tylerdigital May 17, 2023
72a7628
capability check for editing featured image
hsein-bitar May 23, 2023
406c55b
added nonce verification for setting featured image
hsein-bitar May 24, 2023
a00af47
Merge pull request #34 from nsquared-team/fix/security-vulnerability
tylerdigital May 25, 2023
ff69101
Update to 2.0.12 [version-bump]
tylerdigital May 26, 2023
f70793c
excluded release directory from the grunt copy command
hsein-bitar Jun 1, 2023
7ab6123
Merge pull request #36 from nsquared-team/cirelease-fix
hsein-bitar Jun 1, 2023
dce9702
Put leaflet in noConflict mode (#35)
NatalieMac Jun 2, 2023
d111565
Cleanup of required reviewers files
otto-bot-git Jun 2, 2023
cf72bd9
reverted changes and adopted a fix that avoids conflicts with other p…
hsein-bitar Jun 5, 2023
20c80e9
formatting
hsein-bitar Jun 5, 2023
ba15344
Merge pull request #37 from nsquared-team/deprecated-optional-follows…
tylerdigital Jun 6, 2023
4c4347f
Merge pull request #38 from nsquared-team/master
gnarza Jun 19, 2023
d109ddf
Update readme.txt
gnarza Jun 19, 2023
4430810
Merge pull request #39 from nsquared-team/readme-updates
tylerdigital Jun 19, 2023
e26f7f2
Update to 2.0.13 [version-bump]
tylerdigital Jun 25, 2023
9dd2c67
Update tested up to
NatalieMac Aug 2, 2023
3b66ae5
Requiring review from 'tylerdigital' ci bypass
otto-bot-git Aug 2, 2023
33e54d2
Merge pull request #40 from nsquared-team/6-3-update
tylerdigital Aug 2, 2023
b65bd94
Cleanup of required reviewers files
otto-bot-git Aug 2, 2023
9cf58ce
Declare plugin_slug in DrawAttention_Admin
MariamElZaatari Aug 7, 2023
2f1beb9
Declare import_export in DrawAttention
MariamElZaatari Aug 7, 2023
dbecb4e
Declare All missing variables in WP_Drag_Drop_Featured_Image_Map
MariamElZaatari Aug 7, 2023
7eb186a
Merge pull request #41 from nsquared-team/fix-php-deprecation-warnings
tylerdigital Aug 12, 2023
b2d798a
Update to 2.0.14 [version-bump]
tylerdigital Aug 12, 2023
8ccc493
initial code changes to prevent users below admin or editor roles fro…
hsein-bitar Oct 9, 2023
c96f72a
minor fix
hsein-bitar Oct 9, 2023
a3d34e5
tie the logic to a capability not a role
hsein-bitar Oct 11, 2023
d36f2e1
Merge pull request #42 from nsquared-team/vuln-fix
tylerdigital Oct 13, 2023
aa12f0e
added explicit VERSION to the deploy action
hsein-bitar Oct 19, 2023
ae725bc
mark release as latest
hsein-bitar Oct 19, 2023
89b61ce
added scripts needed to format changelog
hsein-bitar Oct 19, 2023
1f535c3
minor fix
hsein-bitar Oct 19, 2023
c7399bf
Merge pull request #43 from nsquared-team/fix-deploy
tylerdigital Oct 19, 2023
ff6c6c9
Update to 2.0.15 [version-bump]
tylerdigital Oct 19, 2023
d49a7b4
initial security fixes
hsein-bitar Oct 25, 2023
14887cb
more permission checks
hsein-bitar Oct 25, 2023
e3484ef
Requiring review from 'cynhu92' ci bypass
otto-bot-git Oct 25, 2023
de839d8
Merge pull request #44 from nsquared-team/nonce-security
hsein-bitar Oct 27, 2023
0513760
Cleanup of required reviewers files
otto-bot-git Oct 27, 2023
6a9069a
Update to 2.0.16 [version-bump]
tylerdigital Oct 29, 2023
6616b89
Tested up to WP 6.3
NatalieMac Oct 31, 2023
513ecd3
Merge pull request #45 from nsquared-team/6-4-update
tylerdigital Nov 1, 2023
0e73695
Update to 2.0.17 [version-bump]
tylerdigital Nov 7, 2023
ba9fcbc
fix conflict with Conditional Featured Image Plugin
hsein-bitar Nov 13, 2023
a697254
Merge pull request #46 from nsquared-team/bugfix-conflict
tylerdigital Nov 14, 2023
181f0b6
automate the release process
hsein-bitar Dec 11, 2023
e0c201c
minor fix
hsein-bitar Dec 11, 2023
485d892
Merge pull request #47 from nsquared-team/automate-weekly-deploy
tylerdigital Dec 12, 2023
15cf5ba
Update to 2.0.18 [version-bump]
tylerdigital Dec 12, 2023
8b46d82
Update readme.txt
gnarza Dec 28, 2023
6a5913b
Merge pull request #48 from nsquared-team/readme-updates-2
tylerdigital Dec 31, 2023
37b42f1
Update to 2.0.19 [version-bump]
tylerdigital Jan 2, 2024
4238427
fix include path
hsein-bitar Jan 17, 2024
2919752
minor fix
hsein-bitar Jan 17, 2024
2460db7
Merge pull request #49 from nsquared-team/includes-fix
tylerdigital Jan 17, 2024
96e5776
Update to 2.0.20 [version-bump]
tylerdigital Jan 23, 2024
fb65fea
initial workflow to format the code in the CI pipline
hsein-bitar Feb 13, 2024
d41a137
attempt to ignore minified files
hsein-bitar Feb 13, 2024
59f2856
working solution
hsein-bitar Feb 13, 2024
d21ef28
added .prettierignore
hsein-bitar Feb 13, 2024
2086437
test
hsein-bitar Feb 13, 2024
3ca8093
fixed eslint setup
hsein-bitar Feb 13, 2024
11c5f9d
Automated code formatting on branch done.
otto-bot-git Feb 13, 2024
242c466
test again
hsein-bitar Feb 13, 2024
f1c96a3
Merge branch 'auto-format' of github.com:nsquared-team/draw-attention…
hsein-bitar Feb 13, 2024
96728d5
Requiring review from 'cynhu92' ci bypass
otto-bot-git Feb 14, 2024
56ffd0b
avoid formatting minified file public/assets/js/leaflet.js
hsein-bitar Feb 14, 2024
6a5e45d
Requiring review from 'gnarza' ci bypass
otto-bot-git Feb 14, 2024
ed3d4ae
Requiring review from 'cynhu92' ci bypass
otto-bot-git Feb 14, 2024
91411fe
Merge pull request #50 from nsquared-team/auto-format
hsein-bitar Feb 14, 2024
b38eb19
Cleanup of required reviewers files
otto-bot-git Feb 14, 2024
2863a5a
Update to 2.0.21 [version-bump]
tylerdigital Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
parserOptions: {
parser: "@babel/eslint-parser",
requireConfigFile: false,
ecmaVersion: "latest",
},
extends: ["plugin:prettier/recommended"],
};
100 changes: 100 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Draw Attention CI workflow

on:
pull_request:

concurrency:
group: da-ci-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

env:
EVENT: ${{ toJSON(github.event) }}

jobs:
# =====================================================================================#
# Run code through PHPCodeSniffer to conform to standards =============================#
# =====================================================================================#
# The installed coding standards are Zend, PEAR, PSR2, Squiz, PSR12, MySource, PSR1, PHPCompatibility, PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP, WordPress, WordPress-Extra, WordPress-Core and WordPress-Docs
static-code-analysis:
name: Static Code Analysis
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
env:
phpcs_config_flags: --standard=WordPress --ignore=vendor,node_modules,*min.* --extensions=php --runtime-set testVersion 7.2
steps:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
coverage: none

- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Set git user information
run: |
git config --global user.email "otto@nsquared.io"
git config --global user.name "otto-bot-git"

- name: Prepare environment
run: |
composer init --name nsquared-team/draw-attention --no-interaction
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --with-all-dependencies --dev dealerdirect/phpcodesniffer-composer-installer:"*" phpcompatibility/phpcompatibility-wp:"*"
composer require --with-all-dependencies --dev wp-coding-standards/wpcs
vendor/bin/phpcs --version
vendor/bin/phpcs -i
vendor/bin/phpcs --config-set colors 1

- name: Install dependencies
run: |
npm install
npm install -g prettier
npm install -g eslint

# =================================================================================================#
# Run code through PHPCodeSniffer to conform to standards ========================================#
# =================================================================================================#

- name: Fix code with PHP Code Sniffer
if: always()
continue-on-error: true
run: |
vendor/bin/phpcbf -p "." ${{ env.phpcs_config_flags }}

- name: Check any remaining errors with PHP Code Sniffer
if: always()
continue-on-error: true
run: |
vendor/bin/phpcs -p "." ${{ env.phpcs_config_flags }}

# =================================================================================================#
# Run code through Prettier and ESLint to conform to standards ====================================#
# =================================================================================================#

- name: Format JS files
run: prettier --write "**/*.js"

# No Vue files in this project at the moment
# - name: Format Vue files
# run: prettier --write "**/*.vue"

- name: Lint JS files
run: eslint --fix "**/*.js" --ignore-pattern "**/vendor/**/*" --ignore-pattern "**/node_modules/**/*" --ignore-pattern "**/*min.*"

# No Vue files in this project at the moment
# - name: Lint Vue files
# run: eslint --fix "**/*.vue" --ignore-pattern "**/vendor/**/*" --ignore-pattern "**/node_modules/**/*"

- name: Revert unwanted composer changes
run: |
git checkout composer.json
git checkout composer.lock

# The push below will not trigger a new workflow because it uses the default GITHUB_TOKEN
- name: Commit and push changes
run: |
# just a guard, we also should keep on excluding the minified files
git restore "*min.*"
`git add -A && git commit -m "Automated code formatting on branch done." > /dev/null && git push` || true
34 changes: 27 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

name: DA deploy to WordPress.org

# keeping the trigger at released gives us the chance to skip deploying any releases we don't like or whatever
on:
release:
types: [released]
workflow_dispatch:
inputs:
tag_name:
Expand Down Expand Up @@ -99,20 +96,43 @@ jobs:
ASSETS_DIR: assets/repo/
BUILD_DIR: release/draw-attention
SLUG: draw-attention

VERSION: ${{ steps.set_tag_name.outputs.tag_name }}

- name: "Send Deploymnt Notification to Slack"
if: steps.deploy.outcome == 'success'
uses: slackapi/slack-github-action@v1.23.0
env:
JSON: "{\"text\":\"\\n:large_green_circle: Draw Attention ${{ github.event.release.tag_name }}\\nSuccessfully deployed to <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:large_green_circle: Draw Attention ${{ github.event.release.tag_name }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Successfully deployed to <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\"}}]}"
JSON: "{\"text\":\"\\n:large_green_circle: Draw Attention ${{ steps.set_tag_name.outputs.tag_name }}\\nSuccessfully deployed to <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:large_green_circle: Draw Attention ${{ steps.set_tag_name.outputs.tag_name }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Successfully deployed to <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\"}}]}"
with:
payload: ${{ env.JSON }}


- name: "Get release ID"
id: release-data
run: |
response=$(curl -s https://api.github.com/graphql -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -d '{ "query": "query { repository(owner: \"nsquared-team\", name: \"draw-attention\") { release(tagName: \"${{ steps.set_tag_name.outputs.tag_name }}\") { databaseId createdAt } } }" }')
databaseId=$(echo "$response" | jq -r '.data.repository.release.databaseId')
if [[ -z "$databaseId" ]]; then
echo "Error: databaseId is empty"
exit 1
fi
echo "release-id=$databaseId" >> $GITHUB_OUTPUT


- name: "Update release to be latest"
if: steps.deploy.outcome == 'success'
run: |
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$GITHUB_REPOSITORY/releases/${{ steps.release-data.outputs.release-id }} \
-d '{"make_latest":true}'

- name: "Send WP Deployment Failure Warning to Slack"
if: steps.deploy.outcome != 'success'
uses: slackapi/slack-github-action@v1.23.0
env:
JSON: "{\"text\":\"\\n:red_circle: Draw Attention ${{ github.event.release.tag_name }}\\nFailed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:red_circle: Draw Attention ${{ github.event.release.tag_name }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Failed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\"}}]}"
JSON: "{\"text\":\"\\n:red_circle: Draw Attention ${{ steps.set_tag_name.outputs.tag_name }}\\nFailed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:red_circle: Draw Attention ${{ steps.set_tag_name.outputs.tag_name }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Failed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\"}}]}"
with:
payload: ${{ env.JSON }}
87 changes: 70 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@ env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

on:
schedule:
# release every Tuesday at 5pm UTC, LA time 9am
- cron: '0 17 * * 2'
workflow_dispatch:
inputs:
version_type:
description: "Version type (major, minor, patch or leave empty to release current master branch)"
required: false
default: ""

deploy:
description: "Deploy to WordPress.org (true or false)"
required: false
default: "false"

jobs:
github-release:
name: "Create a GitHub Release"
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 10
steps:
- name: "Dump GitHub Context"
env:
Expand All @@ -46,7 +52,9 @@ jobs:
- name: "Check defined version type"
id: version
run: |
if [ "${{ github.event.inputs.version_type }}" == "major" ]; then
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "version=patch" >> $GITHUB_OUTPUT
elif [ "${{ github.event.inputs.version_type }}" == "major" ]; then
echo "version=major" >> $GITHUB_OUTPUT
elif [ "${{ github.event.inputs.version_type }}" == "minor" ]; then
echo "version=minor" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -83,19 +91,29 @@ jobs:
# Build Dev Changelog =================
# =====================================
- name: "Build Dev Changelog"
uses: mikepenz/release-changelog-builder-action@v3
uses: mikepenz/release-changelog-builder-action@v4.0.0-b02
id: build_dev_changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
toTag: ${{ github.ref }}
configuration: "./.github/config/dev_changelog_configuration.json"

# if scheduled and no pull requests caught in changelog, exit
- name: "Exit if no pull requests caught in changelog"
if: github.event_name == 'schedule' && steps.build_dev_changelog.outputs.pull_requests == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "No pull requests caught in changelog. Exiting."
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}

# =====================================
# Build Changelog =====================
# =====================================
- name: "Build Changelog"
uses: mikepenz/release-changelog-builder-action@v3
uses: mikepenz/release-changelog-builder-action@v4.0.0-b02
id: build_changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -196,6 +214,29 @@ jobs:
files: |
${{ env.ZIP_FILENAME }}


- name: "Get release ID"
id: release-data
run: |
response=$(curl -s https://api.github.com/graphql -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -d '{ "query": "query { repository(owner: \"nsquared-team\", name: \"draw-attention\") { release(tagName: \"${{ steps.package-version.outputs.current-version }}\") { databaseId createdAt } } }" }')
databaseId=$(echo "$response" | jq -r '.data.repository.release.databaseId')
if [[ -z "$databaseId" ]]; then
echo "Error: databaseId is empty"
exit 1
fi
echo "release-id=$databaseId" >> $GITHUB_OUTPUT

- name: "Update release to be latest"
run: |
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$GITHUB_REPOSITORY/releases/${{ steps.release-data.outputs.release-id }} \
-d '{"make_latest":true}'


# =====================================
# Send Failure Warning to Slack =======
# =====================================
Expand All @@ -211,20 +252,32 @@ jobs:
# Send Dev Changelog Notification =====
# =====================================
- name: "Format changelog for slack"
id: format-changelog
id: format-dev-changelog
env:
CHANGELOG: ${{ toJson(steps.build_dev_changelog.outputs.changelog) }}
CHANGELOG_JSON: ${{ steps.build_dev_changelog.outputs.categorized }}
CHANGELOG_STRING: ${{ steps.build_dev_changelog.outputs.changelog }}
PROJECT: "Draw Attention"
run: |
no_newline_string=$(echo "$CHANGELOG" | tr -d '\n')
single_quote_string=$(echo "$no_newline_string" | sed "s/\"/'/g")
single_quote_string=$(echo "$single_quote_string" | sed 's/\\\([^n]\)/\1/g')
echo "formatted_changelog=$single_quote_string" >> $GITHUB_OUTPUT

php "external/actions-scripts/format-changelog.php" --version=${{ steps.package-version.outputs.current-version }} --repo=${{ github.repository }} --out="formatted-dev-changelog.json"

- name: "View JSON file"
run: |
cat "formatted-dev-changelog.json"

- name: "Send Dev Changelog Notification to Slack"
if: success()
uses: slackapi/slack-github-action@v1.23.0
run: |
json_content=$(cat "formatted-dev-changelog.json")
curl -X POST -H "Content-type: application/json" --data "$json_content" "${{ env.SLACK_WEBHOOK_URL }}"

# ===================================================================
# Trigger deploy workflow only if the workflow was triggered on cron
# ===================================================================
- name: "Trigger deploying to WordPress.org"
env:
JSON: "{\"text\":\"\\n:large_green_circle: Draw Attention ${{ steps.package-version.outputs.current-version }}\\nSuccessfully Prepared GitHub release.:fox-dance:\\nChangelog:\\n${{steps.format-changelog.outputs.formatted_changelog}}\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:large_green_circle: Draw Attention ${{ steps.package-version.outputs.current-version }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Successfully Prepared GitHub release.:fox-dance:\\nChangelog:\\n${{steps.format-changelog.outputs.formatted_changelog}}\\n\"}}]}"
with:
payload: ${{ env.JSON }}

GH_TOKEN: ${{ github.token }}
if: success() && ( github.event_name == 'schedule' || github.event.inputs.deploy == 'true' )
run: |
echo 'Sleeping for 5 minutes to allow GitHub to create the release'
sleep 300
gh workflow run deploy.yml -f tag_name="${{ steps.package-version.outputs.current-version }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ wp-config.php
wp-content/plugins/akismet/.htaccess
public/assets/config.codekit3

vendor/
# Needed for WP release
node_modules/
release/
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*min.*
public/assets/js/leaflet.js
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## 2.0.17 - 2023-11-07

### Features and Improvements

- Tested up to WP 6.4

## 2.0.16 - 2023-10-29

### Features and Improvements

- Add nonce checks for additional security

## 2.0.15 - 2023-10-19

### Fixes

- Fix disclosed vulnerability affecting Contributor-level users

## 2.0.14 - 2023-08-12

### Features and Improvements

- Tested up to WP 6.3

## 2.0.13 - 2023-06-25

### Fixes

- Fix PHP warning in CMB2 library

### Features and Improvements

- Prevent conflicts with other plugins that use the leaflet library

## 2.0.12 - 2023-05-26

### Features and Improvements

- Improved nonce verification and capability checks

## 2.0.11 - 2023-05-12

### Fixes
Expand Down
Loading
Loading