Skip to content

Commit

Permalink
Restructure command
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed May 20, 2024
1 parent 0670fae commit af8b165
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
10 changes: 6 additions & 4 deletions packages/toolkit/PROJECTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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 <branch> [--method=<rsync>]
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`.
13 changes: 4 additions & 9 deletions packages/toolkit/project/gitlab/.gitlab-ci.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deploy_production:
name: WPE Production
url: {{url}}
variables:
GIT_URL: {{{deploy_to}}
GIT_URL: {{deploy_to}}
only:
refs:
- {{branch}}
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/project/local/.tenup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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}}"
staging:
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}}"
2 changes: 1 addition & 1 deletion packages/toolkit/utils/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/../`);
Expand Down

0 comments on commit af8b165

Please sign in to comment.