From 3dac31aab4399c797dd31c04582721c167398dc5 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 24 Mar 2022 15:45:29 +0100 Subject: [PATCH 01/24] Accept the username from the ENV --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index b75416d4..17966737 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,6 +34,7 @@ module.exports = function( grunt ) { build_dir: '<%= dist_dir %>', assets_dir: 'assets', deploy_tag: false, + svn_user: process.env.DEPLOY_SVN_USERNAME, }, trunk: { deploy_trunk: true, From 8635662f19ad567f4edd5f2e072d349905f38732 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 24 Mar 2022 16:07:29 +0100 Subject: [PATCH 02/24] Use the stable tags from now on --- Gruntfile.js | 8 ++------ readme.txt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 17966737..0d8045f1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,12 +33,8 @@ module.exports = function( grunt ) { plugin_slug: 'two-factor', build_dir: '<%= dist_dir %>', assets_dir: 'assets', - deploy_tag: false, svn_user: process.env.DEPLOY_SVN_USERNAME, - }, - trunk: { - deploy_trunk: true, - }, + } }, } ); @@ -52,7 +48,7 @@ module.exports = function( grunt ) { grunt.registerTask( 'deploy', [ 'build', - 'wp_deploy:trunk', + 'wp_deploy', ] ); }; diff --git a/readme.txt b/readme.txt index 9bd7f6ef..82c07d0b 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: two factor, two step, authentication, login, totp, fido u2f, u2f, email, b Requires at least: 4.3 Tested up to: 5.9 Requires PHP: 5.6 -Stable tag: trunk +Stable tag: 0.7.1 Enable Two-Factor Authentication using time-based one-time passwords (OTP, Google Authenticator), Universal 2nd Factor (FIDO U2F, YubiKey), email and backup verification codes. From f18549e7a8f582c1505b86db37864d9fa20f0c6e Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 24 Mar 2022 16:21:54 +0100 Subject: [PATCH 03/24] Accept config from ENV vars --- Gruntfile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 0d8045f1..31b38743 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,7 +33,10 @@ module.exports = function( grunt ) { plugin_slug: 'two-factor', build_dir: '<%= dist_dir %>', assets_dir: 'assets', + skip_confirmation: process.env.DEPLOY_SKIP_CONFIRMATION, svn_user: process.env.DEPLOY_SVN_USERNAME, + deploy_tag: process.env.DEPLOY_TAG, + deploy_trunk: process.env.DEPLOY_TRUNK, } }, } ); From eaead33cd0c29c5964ef4d75bc0b1c77ed226a9e Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 24 Mar 2022 16:22:09 +0100 Subject: [PATCH 04/24] Add the deploy sequence using the existing tooling --- .github/workflows/deploy.yml | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..16d84d0f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy + +on: + push: + # TODO: Limit to master branch for trunk deployments and all tags. + branches: + tags: + +jobs: + + deploy: + name: Deploy to WordPress.org + runs-on: ubuntu-20.04 + needs: test + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + cache: 'npm' + node-version-file: '.nvmrc' + + - name: Setup PHP and Composer + uses: shivammathur/setup-php@v2 + with: + php-version: '5.6' + tools: composer:v2 + + - name: Install NPM dependencies + run: npm install + + #- name: Authenticate with WordPress.org SVN + # run: svn co --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ + + - name: Deploy to WordPress.org SVN + env: + DEPLOY_SVN_USERNAME: ${{ secrets.DEPLOY_SVN_USERNAME }} + DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} + DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} + DEPLOY_SKIP_CONFIRMATION: true + run: | + printenv + npm run deploy From e26921b4bc660f81e105a4e9ee0c59b2b5d6da59 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 24 Mar 2022 16:29:10 +0100 Subject: [PATCH 05/24] On all for now --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 16d84d0f..7d41c493 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,8 +3,8 @@ name: Deploy on: push: # TODO: Limit to master branch for trunk deployments and all tags. - branches: - tags: + branches: '**' + tags: '**' jobs: From 52d3c912b5a10c3c937a471169c1d8f842d2d57e Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:24:43 +0300 Subject: [PATCH 06/24] Match the stable tag --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 23cffae0..52229961 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: two factor, two step, authentication, login, totp, fido u2f, u2f, email, b Requires at least: 4.3 Tested up to: 6.0 Requires PHP: 5.6 -Stable tag: 0.7.1 +Stable tag: 0.7.2 Enable Two-Factor Authentication using time-based one-time passwords (OTP, Google Authenticator), Universal 2nd Factor (FIDO U2F, YubiKey), email and backup verification codes. From 019e158ad93cf2d4f8888abb0a461bf680b26aea Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:25:02 +0300 Subject: [PATCH 07/24] Adjust the conditionals for the run --- .github/workflows/deploy.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7d41c493..d0ddb4f2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,9 +2,12 @@ name: Deploy on: push: - # TODO: Limit to master branch for trunk deployments and all tags. - branches: '**' - tags: '**' + branches: + - master + # TODO: Uses for testing this pull request only. Remove before merge! + - '**' + release: + types: [published] jobs: @@ -40,6 +43,4 @@ jobs: DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} DEPLOY_SKIP_CONFIRMATION: true - run: | - printenv - npm run deploy + run: npm run deploy From 2f5e2a7b730e67bc6c126d07f8cc760c6be13ecc Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:26:14 +0300 Subject: [PATCH 08/24] We assume that only stable things get tagged or merged to master --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d0ddb4f2..1e651bd4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,6 @@ jobs: deploy: name: Deploy to WordPress.org runs-on: ubuntu-20.04 - needs: test steps: - name: Checkout uses: actions/checkout@v3 From 95d6721f24d089698d9d1311784fd3619ffd5212 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:29:44 +0300 Subject: [PATCH 09/24] Add a task --- Gruntfile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 31b38743..9e3983c4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,11 +33,13 @@ module.exports = function( grunt ) { plugin_slug: 'two-factor', build_dir: '<%= dist_dir %>', assets_dir: 'assets', + }, + wporg: { skip_confirmation: process.env.DEPLOY_SKIP_CONFIRMATION, svn_user: process.env.DEPLOY_SVN_USERNAME, deploy_tag: process.env.DEPLOY_TAG, deploy_trunk: process.env.DEPLOY_TRUNK, - } + }, }, } ); From c52e63e98fa434be94c80f05422ba46bd1b054b6 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:32:08 +0300 Subject: [PATCH 10/24] Add the deploy badge too --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 85722856..103c93bb 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Two-Factor -[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) +[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) [![Deploy](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml) Two-Factor plugin for WordPress. [View on WordPress.org →](https://wordpress.org/plugins/two-factor/) From 5e14cb62355fc24589f6843d6c947c075db4d4d2 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:45:09 +0300 Subject: [PATCH 11/24] Deploy only if configured --- .github/workflows/deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1e651bd4..d37bf087 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,10 +33,12 @@ jobs: - name: Install NPM dependencies run: npm install - #- name: Authenticate with WordPress.org SVN - # run: svn co --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ + - name: Authenticate with WordPress.org SVN + if: secrets.DEPLOY_SVN_USERNAME + run: svn co --non-interactive --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn - name: Deploy to WordPress.org SVN + if: secrets.DEPLOY_SVN_USERNAME env: DEPLOY_SVN_USERNAME: ${{ secrets.DEPLOY_SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} From b838d560d454789c29b6fe00e2369d60a7852845 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:46:56 +0300 Subject: [PATCH 12/24] =?UTF-8?q?The=20docs=20said=20they=20would=20be=20e?= =?UTF-8?q?valuate=20as=20expressions=20by=20default=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d37bf087..916782d9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,11 +34,11 @@ jobs: run: npm install - name: Authenticate with WordPress.org SVN - if: secrets.DEPLOY_SVN_USERNAME + if: ${{ secrets.DEPLOY_SVN_USERNAME }} run: svn co --non-interactive --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn - name: Deploy to WordPress.org SVN - if: secrets.DEPLOY_SVN_USERNAME + if: ${{ secrets.DEPLOY_SVN_USERNAME }} env: DEPLOY_SVN_USERNAME: ${{ secrets.DEPLOY_SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} From 9f73ace429388bcb877fe74b26531978063ec6b9 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:52:04 +0300 Subject: [PATCH 13/24] =?UTF-8?q?Well,=20turns=20out=20you=20can=E2=80=99t?= =?UTF-8?q?=20reference=20secrets=20in=20if=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 916782d9..d1ba1f83 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,14 +34,13 @@ jobs: run: npm install - name: Authenticate with WordPress.org SVN - if: ${{ secrets.DEPLOY_SVN_USERNAME }} run: svn co --non-interactive --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn - name: Deploy to WordPress.org SVN - if: ${{ secrets.DEPLOY_SVN_USERNAME }} env: DEPLOY_SVN_USERNAME: ${{ secrets.DEPLOY_SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} DEPLOY_SKIP_CONFIRMATION: true + if: env.DEPLOY_SVN_USERNAME run: npm run deploy From aafa0602a1ea73b51be2d4324b8a2df4b3d5c927 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:52:41 +0300 Subject: [PATCH 14/24] Escape the username too --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d1ba1f83..75fe517c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,7 +34,7 @@ jobs: run: npm install - name: Authenticate with WordPress.org SVN - run: svn co --non-interactive --username ${{ secrets.DEPLOY_SVN_USERNAME }} --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn + run: svn co --non-interactive --username "${{ secrets.DEPLOY_SVN_USERNAME }}" --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn - name: Deploy to WordPress.org SVN env: From 587648a9f2b0c62648e591b9c3ee957175ae6457 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 10:56:12 +0300 Subject: [PATCH 15/24] Use a faster command to authenticate --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 75fe517c..277a2ad8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,7 +34,7 @@ jobs: run: npm install - name: Authenticate with WordPress.org SVN - run: svn co --non-interactive --username "${{ secrets.DEPLOY_SVN_USERNAME }}" --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ /tmp/two-factor-svn + run: svn info --non-interactive --username "${{ secrets.DEPLOY_SVN_USERNAME }}" --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ - name: Deploy to WordPress.org SVN env: From 9d33b0674cd9df526d6348a926f2f0eede359f23 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 14 Sep 2022 11:58:43 +0300 Subject: [PATCH 16/24] Pass as options --- Gruntfile.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9e3983c4..c6952c6b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -35,10 +35,12 @@ module.exports = function( grunt ) { assets_dir: 'assets', }, wporg: { - skip_confirmation: process.env.DEPLOY_SKIP_CONFIRMATION, - svn_user: process.env.DEPLOY_SVN_USERNAME, - deploy_tag: process.env.DEPLOY_TAG, - deploy_trunk: process.env.DEPLOY_TRUNK, + options: { + skip_confirmation: process.env.DEPLOY_SKIP_CONFIRMATION, + svn_user: process.env.DEPLOY_SVN_USERNAME, + deploy_tag: process.env.DEPLOY_TAG, + deploy_trunk: process.env.DEPLOY_TRUNK, + }, }, }, } ); From fb4689cf26a44b363a094471a092f38f9dd61fa6 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Thu, 22 Sep 2022 10:12:59 -0500 Subject: [PATCH 17/24] Update .github/workflows/deploy.yml Co-authored-by: Dion Hulse --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 277a2ad8..6e9255a0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,11 +34,11 @@ jobs: run: npm install - name: Authenticate with WordPress.org SVN - run: svn info --non-interactive --username "${{ secrets.DEPLOY_SVN_USERNAME }}" --password "${{ secrets.DEPLOY_SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ + run: svn info --non-interactive --username "${{ secrets.SVN_USERNAME }}" --password "${{ secrets.SVN_PASSWORD }}" https://plugins.svn.wordpress.org/two-factor/ - name: Deploy to WordPress.org SVN env: - DEPLOY_SVN_USERNAME: ${{ secrets.DEPLOY_SVN_USERNAME }} + DEPLOY_SVN_USERNAME: ${{ secrets.SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} DEPLOY_SKIP_CONFIRMATION: true From dda4b4cea982eb19ffebe04584912c3ffff291ac Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:31:46 +0300 Subject: [PATCH 18/24] Debug Env values --- .github/workflows/deploy.yml | 1 + Gruntfile.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e9255a0..3b9d96f6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,6 +41,7 @@ jobs: DEPLOY_SVN_USERNAME: ${{ secrets.SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} + ENV_TEST_TRUE: ${{ contains( github.ref_type, 'branch' ) }} DEPLOY_SKIP_CONFIRMATION: true if: env.DEPLOY_SVN_USERNAME run: npm run deploy diff --git a/Gruntfile.js b/Gruntfile.js index c6952c6b..64078100 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,6 +11,8 @@ module.exports = function( grunt ) { invert: true, } ); + console.log( 'tag:', process.env.DEPLOY_TAG, 'trunk:', process.env.DEPLOY_TRUNK, 'test', process.env.ENV_TEST_TRUE ); + grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), From 7a93cc831cf3507fd40543735cc4f1ed1b3467f8 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:35:00 +0300 Subject: [PATCH 19/24] Debug types too --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 64078100..70ac0a5f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,7 +11,7 @@ module.exports = function( grunt ) { invert: true, } ); - console.log( 'tag:', process.env.DEPLOY_TAG, 'trunk:', process.env.DEPLOY_TRUNK, 'test', process.env.ENV_TEST_TRUE ); + console.log( 'tag:', process.env.DEPLOY_TAG, typeof process.env.DEPLOY_TAG, 'trunk:', process.env.DEPLOY_TRUNK, 'test:', process.env.ENV_TEST_TRUE, typeof process.env.ENV_TEST_TRUE ); grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), From 479ca6e0874b4f5ec713b5a5c314da4686c1b3cf Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:43:35 +0300 Subject: [PATCH 20/24] Use a helper to resolve truthy values from CLI or ENV variables --- Gruntfile.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 70ac0a5f..76e5f16b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,7 +11,15 @@ module.exports = function( grunt ) { invert: true, } ); - console.log( 'tag:', process.env.DEPLOY_TAG, typeof process.env.DEPLOY_TAG, 'trunk:', process.env.DEPLOY_TRUNK, 'test:', process.env.ENV_TEST_TRUE, typeof process.env.ENV_TEST_TRUE ); + /** + * Check if CLI input appears to indicate a truthy value. + * + * @param {string} input Value to check. + * @return {boolean} If value appears to be truthy. + */ + function isTruthy( input ) { + return ( '1' === input || 'true' === input ); + } grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), @@ -38,10 +46,10 @@ module.exports = function( grunt ) { }, wporg: { options: { - skip_confirmation: process.env.DEPLOY_SKIP_CONFIRMATION, + skip_confirmation: isTruthy( process.env.DEPLOY_SKIP_CONFIRMATION ), svn_user: process.env.DEPLOY_SVN_USERNAME, - deploy_tag: process.env.DEPLOY_TAG, - deploy_trunk: process.env.DEPLOY_TRUNK, + deploy_tag: isTruthy( process.env.DEPLOY_TAG ), + deploy_trunk: isTruthy( process.env.DEPLOY_TRUNK ), }, }, }, From 20fa197f92420f9a3492066dd186ea28de4e0019 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:44:04 +0300 Subject: [PATCH 21/24] Remove test value --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3b9d96f6..6e9255a0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,7 +41,6 @@ jobs: DEPLOY_SVN_USERNAME: ${{ secrets.SVN_USERNAME }} DEPLOY_TRUNK: ${{ contains( github.ref_name, 'master' ) }} DEPLOY_TAG: ${{ contains( github.ref_type, 'tag' ) }} - ENV_TEST_TRUE: ${{ contains( github.ref_type, 'branch' ) }} DEPLOY_SKIP_CONFIRMATION: true if: env.DEPLOY_SVN_USERNAME run: npm run deploy From eb0b82876fb0ef3469bc350957681c010dcdb556 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:53:25 +0300 Subject: [PATCH 22/24] Deploy assets only if anything else is deployable --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index 76e5f16b..22070134 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,6 +50,7 @@ module.exports = function( grunt ) { svn_user: process.env.DEPLOY_SVN_USERNAME, deploy_tag: isTruthy( process.env.DEPLOY_TAG ), deploy_trunk: isTruthy( process.env.DEPLOY_TRUNK ), + assets_dir: ( isTruthy( process.env.DEPLOY_TAG ) || isTruthy( process.env.DEPLOY_TRUNK ) ) ? 'assets' : null, }, }, }, From aa2407a9a14d45d9c60afc63da8da4e80e123857 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 11:54:59 +0300 Subject: [PATCH 23/24] Remove debug runs --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e9255a0..3459c03b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,11 +1,10 @@ name: Deploy +# Run deploy only on tag and master builds. on: push: branches: - master - # TODO: Uses for testing this pull request only. Remove before merge! - - '**' release: types: [published] From 798b1ed9c7d03c135608adca4fe889a579416942 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Wed, 12 Oct 2022 12:00:50 +0300 Subject: [PATCH 24/24] Document the deployments --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 103c93bb..9189fd25 100644 --- a/readme.md +++ b/readme.md @@ -21,6 +21,10 @@ Here is how to get started: Then open [a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) with the suggested changes. +## Deployments + +Deployments [to WP.org plugin repository](https://wordpress.org/plugins/two-factor/) are handled automatically by the GitHub action [.github/workflows/deploy.yml](.github/workflows/deploy.yml). All merges to the `master` branch are commited to the [`trunk` directory](https://plugins.trac.wordpress.org/browser/two-factor/trunk) while all [Git tags](https://github.com/WordPress/two-factor/tags) are pushed as versioned releases [under the `tags` directory](https://plugins.trac.wordpress.org/browser/two-factor/tags). + ## Known Issues - PHP codebase doesn't pass the WordPress coding standard checks, see [#437](https://github.com/WordPress/two-factor/issues/437).