diff --git a/packages/toolkit/PROJECTS.md b/packages/toolkit/PROJECTS.md index fed8dafa..47a38128 100644 --- a/packages/toolkit/PROJECTS.md +++ b/packages/toolkit/PROJECTS.md @@ -1,4 +1,6 @@ -# 10up Projects +# 10up Projects (BETA) + +**This subcommand is currently in BETA** 10up Toolkit provides a number of utlities for creating, managing, and deploying 10up specific projects. @@ -32,6 +34,7 @@ environments: deploy_to: "gitlab@1.1.1.1:/var/www/my-project" deploy_to_subdir: "wp-content/" deploy_from: "./" + deploy_type: "rsync" url: "https://environmenturl.com" staging: branch: "staging" @@ -39,6 +42,7 @@ environments: deploy_to: "gitlab@1.1.1.1:/var/www/my-project" deploy_to_subdir: "wp-content/" deploy_from: "./" + deploy_type: "rsync" url: "https://environmenturl.com" ``` @@ -52,6 +56,8 @@ environments: In this scenario, `deploy_from` would be set to `wp` and `deploy_to_subdir` would be `./`. +`deploy_type` currently supports `rsync`, `wpe` (WP Engine), and `pantheon`. It defaults to `rsync`. If WPE or Pantheon is choosen, `deploy_to` should contain a Git URL. More deploy types will be added in the future. + The following are additional optional variables that allow you to use custom scripts different than the ones provided by 10up Toolkit. You shouldn't need to use these unless you are doing something super custom. All these paths are relative from the root of your project. ```yaml @@ -89,4 +95,6 @@ This command creates a payload directory of the built project (including WordPre 10up-toolkit project generate-ci [--confirm] ``` -This command generates necessary CI files. For GitLab, this would be `.gitlab-ci.yml`. +This command generates necessary CI files. For GitLab, this would be `.gitlab-ci.yml`. Right now this only supports GitLab but we will add support for GitHub in the future. + +**Note that generating CI files is currently in alpha and may require manual editing to fix issues.** diff --git a/packages/toolkit/project/gitlab/deploy-configs/pantheon-production.tmpl b/packages/toolkit/project/gitlab/deploy-configs/pantheon-production.tmpl index e69de29b..a3b01e80 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/pantheon-production.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/pantheon-production.tmpl @@ -0,0 +1,14 @@ +deploy_production: + extends: .wordpress-deploy-pantheon-v2 + environment: + name: Production + url: {{url}} + variables: + MULTI_DEV_ENVIRONMENT: "{{branch}}" + WORDPRESS_VERSION: {{wordpress_version}} + GIT_URL: {{deploy_to}} + EXCLUDES: {{deploy_file_excludes}} + allow_failure: false + only: + refs: + - {{branch}} diff --git a/packages/toolkit/project/gitlab/deploy-configs/pantheon-staging.tmpl b/packages/toolkit/project/gitlab/deploy-configs/pantheon-staging.tmpl index e69de29b..a4bc4a2f 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/pantheon-staging.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/pantheon-staging.tmpl @@ -0,0 +1,14 @@ +deploy_{{branch}}: + extends: .wordpress-deploy-pantheon-v2 + environment: + name: {{branch}} + url: {{url}} + variables: + MULTI_DEV_ENVIRONMENT: "{{branch}}" + WORDPRESS_VERSION: {{wordpress_version}} + GIT_URL: {{deploy_to}} + EXCLUDES: {{deploy_file_excludes}} + allow_failure: false + only: + refs: + - {{branch}} diff --git a/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl b/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl index 9cb06908..36820df4 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl @@ -1,11 +1,13 @@ deploy_production: stage: deploy + extends: .wordpress-deploy-rsync environment: name: Production url: {{url}} - script: - - rsync -vrxc --delete --exclude-from={{deploy_file_excludes}} ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ - only: - - {{branch}} variables: - WORDPRESS_VERSION: {{wordpress_version}} + DESTINATION: {{deploy_to}} + SUBDIR: {{deploy_to_subdir}} + EXCLUDES: {{deploy_file_excludes}} + only: + refs: + - {{branch}} diff --git a/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl b/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl index 63c22738..5f47a7f5 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl @@ -1,11 +1,13 @@ -deploy_stage: +deploy_{{branch}}: stage: deploy + extends: .wordpress-deploy-rsync environment: - name: Staging + name: {{branch}} url: {{url}} - script: - - rsync -vrxc --delete --exclude-from={{deploy_file_excludes}} ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ - only: - - {{branch}} variables: - WORDPRESS_VERSION: {{wordpress_version}} + DESTINATION: {{deploy_to}} + SUBDIR: {{deploy_to_subdir}} + EXCLUDES: {{deploy_file_excludes}} + only: + refs: + - {{branch}} diff --git a/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl b/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl index 1abdebfe..e85cd66a 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl @@ -2,7 +2,7 @@ deploy_production: stage: deploy extends: .wordpress-deploy-wpe environment: - name: WPE Production + name: Production url: {{url}} variables: GIT_URL: {{deploy_to}} diff --git a/packages/toolkit/project/gitlab/deploy-configs/wpe-staging.tmpl b/packages/toolkit/project/gitlab/deploy-configs/wpe-staging.tmpl index 03135ca8..7ddf6f4c 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/wpe-staging.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/wpe-staging.tmpl @@ -1,8 +1,8 @@ -deploy_stage: +deploy_{{branch}}: stage: deploy extends: .wordpress-deploy-wpe environment: - name: WPE Staging + name: {{branch}} url: {{url}} variables: GIT_URL: {{deploy_to}} diff --git a/packages/toolkit/scripts/project/generate-ci.js b/packages/toolkit/scripts/project/generate-ci.js index 86983a60..7177c8ad 100644 --- a/packages/toolkit/scripts/project/generate-ci.js +++ b/packages/toolkit/scripts/project/generate-ci.js @@ -52,9 +52,13 @@ const run = async (cnf = false) => { value: 'gitlab', }, { + name: 'None', + value: 'none', + }, + /* { name: 'GitHub', value: 'github', - }, + }, */ ], message: 'Choose a CI type:', }); @@ -66,6 +70,10 @@ const run = async (cnf = false) => { type = results.type || type; + if (type === 'none') { + return; + } + if (type === 'gitlab') { // Load template file into a string const template = fs.readFileSync( @@ -80,19 +88,22 @@ const run = async (cnf = false) => { const fileEnv = env === 'production' ? 'production' : 'staging'; - if (!environment.deploy_type || environment.deploy_type === 'rsync') { - const deployTemplate = fs.readFileSync( - resolve(__dirname, `../../project/gitlab/deploy-configs/rsync-${fileEnv}.tmpl`), - 'utf8', - ); + let filePath = `../../project/gitlab/deploy-configs/rsync-${fileEnv}.tmpl`; - const preparedDeployTemplate = replaceVariables(deployTemplate, { - ...variables, - ...environment, - }); - - preparedTemplate += `\n${preparedDeployTemplate}`; + if (environment.deploy_type === 'wpe' || environment.deploy_type === 'wpengine') { + filePath = `../../project/gitlab/deploy-configs/wpe-${fileEnv}.tmpl`; + } else if (environment.deploy_type === 'pantheon') { + filePath = `../../project/gitlab/deploy-configs/pantheon-${fileEnv}.tmpl`; } + + const deployTemplate = fs.readFileSync(resolve(__dirname, filePath), 'utf8'); + + const preparedDeployTemplate = replaceVariables(deployTemplate, { + ...variables, + ...environment, + }); + + preparedTemplate += `\n${preparedDeployTemplate}`; }); fs.writeFileSync(`${root}/.gitlab-ci.yml`, preparedTemplate);