From 49a88565fd805d80baf693f71eb7cbb383ed5b91 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:07:11 -0500 Subject: [PATCH 1/9] Add hook to test staging deploys --- plugin.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugin.php b/plugin.php index c488a89..363a796 100644 --- a/plugin.php +++ b/plugin.php @@ -19,3 +19,19 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; + +/** + * Initialize plugin functionality on WordPress init. + * Adds custom content to the site header. + * + * @return void + */ + +// Add action to wp_head to insert content in header. +add_action( + 'wp_head', + function() { + // Output custom meta tags or other header content. + echo 'JUST A TEST'; + } +); From c0b3d337bf639bab6338c0d4e1d1bd01b6fdd794 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:09:38 -0500 Subject: [PATCH 2/9] In order to make an action reusable, we need to add on:workflow_call --- .github/workflows/linting.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b30be33..dd104a9 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,6 +1,7 @@ name: Static Linting on: + workflow_call: pull_request: push: branches: From e07047b0a610fb76e6bb94e3e9c50141eb14a56a Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:15:24 -0500 Subject: [PATCH 3/9] Try using concurrency to control the order of jobs occuring. --- .github/workflows/deploy-to-staging.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-to-staging.yml b/.github/workflows/deploy-to-staging.yml index bfbf5e2..d1498c2 100644 --- a/.github/workflows/deploy-to-staging.yml +++ b/.github/workflows/deploy-to-staging.yml @@ -8,6 +8,9 @@ on: jobs: Linting: uses: ./.github/workflows/linting.yml + concurrency: + group: staging-deploy + cancel-in-progress: true Deploy: name: FTP-Deploy-Action From ab21872179ba9296b765d5361c62ed199fc64958 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:25:42 -0500 Subject: [PATCH 4/9] Add concurrency so only one deploy can run at a time. Check for linting failure before running the deploy on staging. --- .github/workflows/deploy-to-prod.yml | 2 ++ .github/workflows/deploy-to-staging.yml | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-to-prod.yml b/.github/workflows/deploy-to-prod.yml index 5e2df21..29a1fcc 100644 --- a/.github/workflows/deploy-to-prod.yml +++ b/.github/workflows/deploy-to-prod.yml @@ -1,5 +1,7 @@ name: Deploy plugin to Production +concurrency: production + on: workflow_dispatch: workflow_run: diff --git a/.github/workflows/deploy-to-staging.yml b/.github/workflows/deploy-to-staging.yml index d1498c2..75ad23a 100644 --- a/.github/workflows/deploy-to-staging.yml +++ b/.github/workflows/deploy-to-staging.yml @@ -1,5 +1,7 @@ name: Deploy plugin to Staging +concurrency: staging + on: push: branches: @@ -7,10 +9,7 @@ on: jobs: Linting: - uses: ./.github/workflows/linting.yml - concurrency: - group: staging-deploy - cancel-in-progress: true + Deploy: name: FTP-Deploy-Action @@ -20,7 +19,11 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 2 + - name: Linting + id: linting + uses: ./.github/workflows/linting.yml - name: FTP-Deploy-Action + if: steps.linting.outcome == 'success' uses: Automattic/FTP-Deploy-Action@3.1.2 with: ftp-server: sftp://sftp.wp.com/htdocs/wp-content/plugins/custom-plugin/ From 26a2279a84a2de7074cdcf5306f2c1041c826470 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:26:48 -0500 Subject: [PATCH 5/9] Remove old job --- .github/workflows/deploy-to-staging.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy-to-staging.yml b/.github/workflows/deploy-to-staging.yml index 75ad23a..0613be5 100644 --- a/.github/workflows/deploy-to-staging.yml +++ b/.github/workflows/deploy-to-staging.yml @@ -8,9 +8,6 @@ on: - staging jobs: - Linting: - - Deploy: name: FTP-Deploy-Action runs-on: ubuntu-latest From 50f9d01c4792577b50da354fea2d66da2577e935 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:34:00 -0500 Subject: [PATCH 6/9] Use the needs keyword to control deploy. --- .github/workflows/deploy-to-staging.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-to-staging.yml b/.github/workflows/deploy-to-staging.yml index 0613be5..61c124f 100644 --- a/.github/workflows/deploy-to-staging.yml +++ b/.github/workflows/deploy-to-staging.yml @@ -1,26 +1,23 @@ name: Deploy plugin to Staging -concurrency: staging - on: push: branches: - staging jobs: + Linting: + uses: ./.github/workflows/linting.yml + Deploy: name: FTP-Deploy-Action runs-on: ubuntu-latest - + needs: Linting steps: - uses: actions/checkout@v3 with: fetch-depth: 2 - - name: Linting - id: linting - uses: ./.github/workflows/linting.yml - name: FTP-Deploy-Action - if: steps.linting.outcome == 'success' uses: Automattic/FTP-Deploy-Action@3.1.2 with: ftp-server: sftp://sftp.wp.com/htdocs/wp-content/plugins/custom-plugin/ From 7b9b975f21eeba87e709f8d9a864ce8459e1adb7 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:34:26 -0500 Subject: [PATCH 7/9] Add concurrency back. --- .github/workflows/deploy-to-staging.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy-to-staging.yml b/.github/workflows/deploy-to-staging.yml index 61c124f..5ec3e42 100644 --- a/.github/workflows/deploy-to-staging.yml +++ b/.github/workflows/deploy-to-staging.yml @@ -1,5 +1,7 @@ name: Deploy plugin to Staging +concurrency: staging + on: push: branches: From db6bbee2454206290c8f479b83b031c0b6a04d86 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:37:03 -0500 Subject: [PATCH 8/9] Introduce linting failures. --- plugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.php b/plugin.php index 363a796..7cd7eb1 100644 --- a/plugin.php +++ b/plugin.php @@ -32,6 +32,9 @@ 'wp_head', function() { // Output custom meta tags or other header content. + if($name ==== 'test') { + echo 'JUST A TEST'; + ] } ); From 360a72f11a5e1cf51dcdebf98bcdcf7ca5648145 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Thu, 6 Feb 2025 15:38:42 -0500 Subject: [PATCH 9/9] Remove linting test code. --- plugin.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/plugin.php b/plugin.php index 7cd7eb1..c488a89 100644 --- a/plugin.php +++ b/plugin.php @@ -19,22 +19,3 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; - -/** - * Initialize plugin functionality on WordPress init. - * Adds custom content to the site header. - * - * @return void - */ - -// Add action to wp_head to insert content in header. -add_action( - 'wp_head', - function() { - // Output custom meta tags or other header content. - if($name ==== 'test') { - - echo 'JUST A TEST'; - ] - } -);