-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from studiopress/develop
Merge 3.3.0 to Master
- Loading branch information
Showing
16 changed files
with
406 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,175 @@ | ||
version: 2.1 | ||
jobs: | ||
standards: | ||
|
||
commands: | ||
install_dependencies: | ||
description: "Install development dependencies." | ||
steps: | ||
- run: composer install | ||
- run: npm ci | ||
mkdir_artifacts: | ||
description: "Make Artifacts directory" | ||
steps: | ||
- run: | ||
command: | | ||
[ ! -d "/tmp/artifacts" ] && mkdir /tmp/artifacts &>/dev/null | ||
executors: | ||
base: | ||
docker: | ||
- image: circleci/buildpack-deps:latest | ||
working_directory: /tmp | ||
php_node: | ||
docker: | ||
- image: circleci/php:7.3.3-stretch-node-browsers | ||
working_directory: /tmp/theme | ||
python: | ||
docker: | ||
- image: circleci/python:3.7-stretch | ||
working_directory: /tmp | ||
|
||
jobs: | ||
checkout: | ||
executor: base | ||
steps: | ||
- checkout: | ||
path: theme | ||
- persist_to_workspace: | ||
root: /tmp | ||
paths: | ||
- theme | ||
|
||
standards: | ||
executor: php_node | ||
steps: | ||
- checkout | ||
- install-dependencies | ||
- attach_workspace: | ||
at: /tmp | ||
- install_dependencies | ||
- run: composer phpcs | ||
- run: npm run lint:css | ||
- run: npm run lint:js | ||
commands: | ||
install-dependencies: | ||
description: "Install development dependencies." | ||
|
||
bundle: | ||
executor: php_node | ||
steps: | ||
- run: composer install | ||
- attach_workspace: | ||
at: /tmp | ||
- run: npm ci | ||
- run: npm run zip | ||
- mkdir_artifacts | ||
- run: mv ./*.zip /tmp/artifacts/. | ||
- persist_to_workspace: | ||
root: /tmp | ||
paths: | ||
- artifacts | ||
- theme | ||
- store_artifacts: | ||
path: /tmp/artifacts/ | ||
|
||
create_data_file: | ||
executor: php_node | ||
steps: | ||
- attach_workspace: | ||
at: /tmp | ||
- run: npm run prep:piservice /tmp/artifacts | ||
- persist_to_workspace: | ||
root: /tmp | ||
paths: | ||
- artifacts | ||
|
||
deploy_s3: | ||
executor: python | ||
steps: | ||
- attach_workspace: | ||
at: /tmp | ||
- aws-s3/sync: | ||
from: "/tmp/artifacts/" | ||
to: "s3://update.atomicblocks.com/themes/${S3_PATH}/" | ||
|
||
deploy_sp_staging: | ||
executor: python | ||
steps: | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "f2:c5:53:4d:39:eb:ba:72:06:4d:fc:48:7c:5a:0f:df" | ||
- attach_workspace: | ||
at: /tmp | ||
- run: | ||
command: | | ||
ARTIFACT_FILE=find /tmp/artifacts -type f -name *.zip -printf "%f\n" | ||
DEST_PATH=home/wpe-user/sites/${STAGING_INSTALL_NAME}/wp-content/uploads/member-access/${ARTIFACT_FILE} | ||
DEST_HOST=${STAGING_INSTALL_NAME}@${STAGING_INSTALL_NAME}.ssh.wpengine.net | ||
scp /tmp/artifacts/${ARTIFACT_FILE} ${DEST_HOST}/${DEST_PATH} | ||
deploy_sp_prod: | ||
executor: python | ||
steps: | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "f2:c5:53:4d:39:eb:ba:72:06:4d:fc:48:7c:5a:0f:df" | ||
- attach_workspace: | ||
at: /tmp | ||
- run: | ||
command: | | ||
ARTIFACT_FILE=find /tmp/artifacts -type f -name *.zip -printf "%f\n" | ||
DEST_PATH=home/wpe-user/sites/${PROD_INSTALL_NAME}/wp-content/uploads/member-access/${ARTIFACT_FILE} | ||
DEST_HOST=${PROD_INSTALL_NAME}@${PROD_INSTALL_NAME}.ssh.wpengine.net | ||
scp /tmp/artifacts/${ARTIFACT_FILE} ${DEST_HOST}/${DEST_PATH} | ||
workflows: | ||
version: 2 | ||
check-standards: | ||
jobs: | ||
- standards | ||
- checkout: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- standards: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
requires: | ||
- checkout | ||
- bundle: | ||
requires: | ||
- standards | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
only: master | ||
- create_data_file: | ||
requires: | ||
- bundle | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
only: master | ||
- deploy_s3: | ||
requires: | ||
- create_data_file | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
only: master | ||
- deploy_sp_staging: | ||
requires: | ||
- create_data_file | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
only: master | ||
- deploy_sp_prod: | ||
requires: | ||
- create_data_file | ||
- deploy_sp_staging | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
only: master | ||
|
||
orbs: | ||
aws-s3: circleci/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ indent_style = tab | |
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,8 @@ | |
/phpcs.xml | ||
node_modules/ | ||
vendor/ | ||
|
||
# Artifacts | ||
process.yml | ||
*.zip | ||
*.*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* Create a JSON file to be consumed by the Product Info Service | ||
* | ||
* @TODO Accept a destination file path via CLI arguments | ||
* @TODO Maybe convert "tags" value to an array? | ||
*/ | ||
const fs = require('fs'); | ||
|
||
/** | ||
* Run the script | ||
*/ | ||
const runScript = function() { | ||
// Set the destination path | ||
const destPath = getDestPath(process.argv[2]); | ||
|
||
// Declare empty data object | ||
let data = {}; | ||
|
||
// Get array of "theme" keys from process.env.npm_package_theme_* | ||
const keys = Object.keys(process.env).filter(key => key.match(/npm_package_theme_.+/)); | ||
|
||
// Iterate through keys and populate the data object | ||
// Note: this isn't using a map because we want the output to be an object, not an array | ||
keys.forEach(envKey => { | ||
key = envKey.match(/npm_package_theme_(.+)/)[1]; // strip npm_package_theme_ from key | ||
data[key] = process.env[envKey]; // Save to data object | ||
}); | ||
|
||
// Write data object to a JSON file | ||
const filePath = `${destPath}/${data.textdomain}.${data.version}.json`; | ||
fs.writeFileSync(filePath, JSON.stringify(data)); | ||
} | ||
|
||
/** | ||
* Get destination path | ||
* | ||
* @param {string} path | ||
* | ||
* @return {string} | ||
*/ | ||
const getDestPath = function(path) { | ||
const defaultPath = process.cwd(); | ||
|
||
// Return default if a path wasn't provided | ||
if( ! path || ! path.length){ | ||
return defaultPath; | ||
} | ||
|
||
// Return default if the provided path doesn't exist | ||
if (!fs.existsSync(path)) { | ||
return defaultPath; | ||
} | ||
|
||
return path; | ||
} | ||
|
||
// Run the script | ||
runScript(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.