Skip to content

Commit

Permalink
Merge pull request #438 from WordPress/add/wporg-deploy-action
Browse files Browse the repository at this point in the history
Add automatic deployments to WP.org
  • Loading branch information
kasparsd authored Oct 12, 2022
2 parents 2ee35c2 + 798b1ed commit 9cde70c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy

# Run deploy only on tag and master builds.
on:
push:
branches:
- master
release:
types: [published]

jobs:

deploy:
name: Deploy to WordPress.org
runs-on: ubuntu-20.04
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 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.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
23 changes: 19 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ module.exports = function( grunt ) {
invert: 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' ),

Expand All @@ -33,10 +43,15 @@ module.exports = function( grunt ) {
plugin_slug: 'two-factor',
build_dir: '<%= dist_dir %>',
assets_dir: 'assets',
deploy_tag: false,
},
trunk: {
deploy_trunk: true,
wporg: {
options: {
skip_confirmation: isTruthy( process.env.DEPLOY_SKIP_CONFIRMATION ),
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,
},
},
},
} );
Expand All @@ -51,7 +66,7 @@ module.exports = function( grunt ) {
grunt.registerTask(
'deploy', [
'build',
'wp_deploy:trunk',
'wp_deploy',
]
);
};
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -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/)

Expand All @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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: trunk
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.

Expand Down

0 comments on commit 9cde70c

Please sign in to comment.