diff --git a/packages/toolkit/PROJECTS.md b/packages/toolkit/PROJECTS.md index 9a9dcc45..fed8dafa 100644 --- a/packages/toolkit/PROJECTS.md +++ b/packages/toolkit/PROJECTS.md @@ -15,13 +15,13 @@ A standard 10up GitLab project initialized with 10up Toolkit looks like the foll `.tenup.yml` contains a number of variables the define the structure of the project e.g. the WordPress version and how to deploy the application. -`.gitlab-ci.yml` is a standard GitLab CI file that never needs to be edited by project teams. +`.gitlab-ci.yml` is a standard GitLab CI file that is generated by 10up Toolkit. It usually doesn't need to be edited but occassionally may need customization for more advanced CI workflows. `build.sh` contains the commands for building a project. Engineers will need to edit this file to ensure it contains the proper build commands. ### .tenup.yml -`.tenup.yml` is automatically generated by the init command but you may want to create one yourself. Also, even after init, you will need to make sure it includes the properly values. Here is the anatomy of the file: +`.tenup.yml` is automatically generated by the init command but you may want to create one yourself. Also, even after init, you will need to make sure it includes the proper values. Here is the anatomy of the file: ```yaml project_name: "10up Project" @@ -32,12 +32,14 @@ environments: deploy_to: "gitlab@1.1.1.1:/var/www/my-project" deploy_to_subdir: "wp-content/" deploy_from: "./" + url: "https://environmenturl.com" staging: branch: "staging" wordpress_version: "6.4" deploy_to: "gitlab@1.1.1.1:/var/www/my-project" deploy_to_subdir: "wp-content/" deploy_from: "./" + url: "https://environmenturl.com" ``` `deploy_from` and `deploy_to_subdir` let you choose what directory of your application deploys to which part of WordPress. `deploy_to` is the full remote path to WordPress. `deploy_from` is relative to the root of your project. `deploy_to_subdir` is relative to `deploy_to`. By default, it's set up such that the root of your application deploys to `wp-content`. Another setup is where your application is one level above WordPress e.g. @@ -84,7 +86,7 @@ List of commands: This command creates a payload directory of the built project (including WordPress) for deployment. Engineers likely won't need to run this command themselves as GitLab does it automatically. You must provide a branch that corresponds to an environment in `.tenup.yml`. ```bash -10up-toolkit project deploy [--method=] +10up-toolkit project generate-ci [--confirm] ``` -This commands deploys the application and is run automatically by GitLab. Project teams will need to ensure all the values are properly set in `.tenup.yml` for deployment to work. You can create a custom deploy script or just use the default rsync method. You must provide a branch that corresponds to an environment in `.tenup.yml`. +This command generates necessary CI files. For GitLab, this would be `.gitlab-ci.yml`. diff --git a/packages/toolkit/project/gitlab/.gitlab-ci.tmpl b/packages/toolkit/project/gitlab/.gitlab-ci.tmpl index 3a8e87fd..235d7e86 100644 --- a/packages/toolkit/project/gitlab/.gitlab-ci.tmpl +++ b/packages/toolkit/project/gitlab/.gitlab-ci.tmpl @@ -7,13 +7,8 @@ include: ref: trunk file: /main.yml -stages: - - setup - - test-and-build - - deploy - setup_10up_toolkit: - stage: setup + stage: .pre script: | if [ ! -d "toolkit" ] ; then git clone --verbose -b project-command https://github.com/10up/10up-toolkit.git toolkit @@ -28,21 +23,21 @@ setup_10up_toolkit: - 10up-toolkit test_syntax: - stage: test-and-build + stage: test script: - php-syntax dependencies: [] cache: {} test_virusscan: - stage: test-and-build + stage: test script: - virus-scan dependencies: [] cache: {} build_plugins_and_themes: - stage: test-and-build + stage: build script: - ./10up-toolkit project create-payload $CI_COMMIT_REF_NAME artifacts: diff --git a/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl b/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl index 0c14afb0..9cb06908 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/rsync-production.tmpl @@ -4,7 +4,7 @@ deploy_production: name: Production url: {{url}} script: - - rsync -vrxc --delete --exclude-from=./deploy-scripts/rsync-excludes.txt ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ + - rsync -vrxc --delete --exclude-from={{deploy_file_excludes}} ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ only: - {{branch}} variables: diff --git a/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl b/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl index da643061..63c22738 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/rsync-staging.tmpl @@ -4,7 +4,7 @@ deploy_stage: name: Staging url: {{url}} script: - - rsync -vrxc --delete --exclude-from=./deploy-scripts/rsync-excludes.txt ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ + - rsync -vrxc --delete --exclude-from={{deploy_file_excludes}} ./payload/ {{deploy_to}}/{{deploy_to_subdir}}/ only: - {{branch}} variables: diff --git a/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl b/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl index d1112cfb..1abdebfe 100644 --- a/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl +++ b/packages/toolkit/project/gitlab/deploy-configs/wpe-production.tmpl @@ -5,7 +5,7 @@ deploy_production: name: WPE Production url: {{url}} variables: - GIT_URL: {{{deploy_to}} + GIT_URL: {{deploy_to}} only: refs: - {{branch}} diff --git a/packages/toolkit/project/local/.tenup.yml b/packages/toolkit/project/local/.tenup.yml index 2ec0128c..22a0e784 100644 --- a/packages/toolkit/project/local/.tenup.yml +++ b/packages/toolkit/project/local/.tenup.yml @@ -4,7 +4,7 @@ environments: branch: "trunk" deploy_type: "rsync" deploy_from: "./" - url: "" + url: "https://example.com" deploy_to: "user@1.1.1.1/path/to/wordpress/" deploy_to_subdir: "wp-content/" wordpress_version: "{{wordpress_version}}" @@ -12,7 +12,7 @@ environments: branch: "staging" deploy_type: "rsync" deploy_from: "./" - url: "" + url: "https://staging.example.com" deploy_to: "user@1.1.1.1/path/to/wordpress/" deploy_to_subdir: "wp-content/" wordpress_version: "{{wordpress_version}}" diff --git a/packages/toolkit/utils/project.js b/packages/toolkit/utils/project.js index 4836d44a..19fc1264 100644 --- a/packages/toolkit/utils/project.js +++ b/packages/toolkit/utils/project.js @@ -139,7 +139,7 @@ const getProjectVariables = () => { } if (!data.deploy_file_excludes) { - data.deploy_file_excludes = resolve(`${__dirname}/../project/deploy-file-excludes.txt`); + data.deploy_file_excludes = `./toolkit/packages/toolkit/project/deploy-file-excludes.txt`; } data.toolkit_path = resolve(`${__dirname}/../`);