Skip to content

Commit aeee68a

Browse files
committed
Merge branch 'deployer7' into feature/update-logo
2 parents 49c0699 + f297719 commit aeee68a

File tree

8 files changed

+358
-396
lines changed

8 files changed

+358
-396
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# W3C website template bundle & Design System
22

3-
The Symfony website templates for [w3.org](https://github.com/w3c/w3c-website-frontend), this also generates the
3+
The Symfony website templates for [w3.org](https://github.com/w3c/w3c-website-frontend). This also generates the
44
static HTML [design system website](https://design-system.w3.org/).
55

66
## Design System
@@ -9,7 +9,7 @@ This repo contains the design system documentation, frontend assets and example
99

1010
Documentation for implementing the W3C website design can be found on the [Design System website](https://design-system.w3.org/).
1111

12-
To make updates or to deploy the design system itself see [design system](design-system.md).
12+
For documentation on how to make updates to the design system itself see [design system README](design-system.md).
1313

1414
Please report any issues to the [w3c-website](https://github.com/w3c/w3c-website/issues) repo.
1515

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"require-dev": {
2828
"studio24/design-system": "dev-main",
29-
"studio24/deployer-recipes": "^v2.0",
29+
"studio24/deployer-recipes": "^v2.1",
3030
"rector/rector": "^1.2"
3131
}
3232
}

composer.lock

Lines changed: 274 additions & 268 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy.php

Lines changed: 33 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -2,147 +2,58 @@
22

33
namespace Deployer;
44

5-
require 'recipe/common.php';
6-
require 'vendor/studio24/deployer-recipes/all.php';
7-
85
/**
9-
* Deployment configuration variables - set on a per-project basis
6+
* 1. Deployer recipes we are using for this website
107
*/
8+
require 'vendor/studio24/deployer-recipes/recipe/static.php';
119

12-
// Friendly project name
13-
$project_name = 'W3C Design System documentation website';
14-
15-
// The repo for the project
16-
$repository = '[email protected]:w3c/w3c-website-templates-bundle.git';
1710

1811
/**
19-
* Apply configuration to Deployer
20-
*
21-
* Don't edit beneath here unless you know what you're doing!
12+
* 2. Deployment configuration variables
2213
*/
2314

24-
set('application', $project_name);
25-
set('repository', $repository);
15+
// Project name
16+
set('application', 'W3C Design System documentation website');
17+
18+
// Git repo
19+
set('repository', '[email protected]:w3c/w3c-website-templates-bundle.git');
20+
21+
// Filesystem volume we're deploying to
22+
set('disk_space_filesystem', '/dev/nvme1n1');
23+
24+
// Default deployment and HTTP users
25+
set('remote_user', 'studio24');
2626
set('http_user', 'apache');
27-
set('webroot', '');
2827
set('keep_releases', 10);
29-
set('git_tty', true);
30-
set('allow_anonymous_stats', false);
31-
32-
// Folder to help build clean copy of design system site
33-
set('build_root', getenv('HOME') . '/.deployer');
3428

3529
// Default stage - prevents accidental deploying to production with dep deploy
36-
set('default_stage', 'staging');
30+
set('default_selector', 'stage=staging');
31+
32+
// Directory that contains built website files
33+
set("build_folder", "_dist");
34+
35+
// Build commands for static site
36+
task('local_build', function() {
37+
runLocally("composer install");
38+
runLocally("./vendor/bin/design-system");
39+
});
3740

3841
/**
39-
* Hosts
42+
* 3. Hosts
4043
*/
4144

45+
localhost('local');
46+
4247
host('production')
43-
->stage('production')
44-
->hostname('proteus.w3.internal')
45-
->user('studio24')
48+
->set('labels', ['stage' => 'production'])
49+
->set('hostname', 'proteus.w3.internal')
50+
->set('remote_user', 'studio24')
4651
->set('deploy_path','/srv/design-system.w3.org')
4752
->set('url', 'https://design-system.w3.org/');
4853

4954
host('staging')
50-
->stage('staging')
51-
->hostname('proteus.w3.internal')
52-
->user('studio24')
55+
->set('labels', ['stage' => 'staging'])
56+
->set('hostname', 'proteus.w3.internal')
57+
->set('remote_user', 'studio24')
5358
->set('deploy_path','/srv/staging-design-system.w3.org')
5459
->set('url', 'https://staging-design-system.w3.org/');
55-
56-
/**
57-
* Deployment task
58-
* The task that will be run when using dep deploy
59-
*/
60-
61-
desc('Deploy ' . get('application'));
62-
task('deploy', [
63-
64-
// Check that we are using local deployer
65-
's24:check-local-deployer',
66-
67-
// Run initial checks
68-
'deploy:info',
69-
's24:check-branch',
70-
's24:display-disk-space',
71-
72-
// Request confirmation to continue (default N)
73-
's24:confirm-continue',
74-
75-
// Deploy site
76-
'deploy:prepare',
77-
'deploy:lock',
78-
'deploy:release',
79-
'local:build',
80-
'deploy:update_code',
81-
82-
// Build complete, deploy is live once deploy:symlink runs
83-
'deploy:symlink',
84-
85-
// Cleanup
86-
'deploy:unlock',
87-
'cleanup',
88-
'success'
89-
]);
90-
91-
// Build tasks
92-
desc('Build Design System website');
93-
task('local:build', function () {
94-
95-
// Set local Deployment directory
96-
$buildRoot = get('build_root');
97-
98-
// Create local Deployment directory
99-
if (!file_exists($buildRoot)) {
100-
writeln('Creating Deployment Directory');
101-
mkdir($buildRoot);
102-
} else {
103-
writeln('Deployment Directory exists, skipping');
104-
}
105-
106-
// Set project root directory for build
107-
$buildPath = $buildRoot.'/'.run('basename {{repository}} .git');
108-
109-
// Remove previous local build
110-
if (!file_exists($buildPath)) {
111-
writeln('No previous build');
112-
} else {
113-
run('rm -rf '.$buildPath);
114-
writeln('Removed previous build');
115-
}
116-
117-
writeln('Cloning Repository (Branch: <info>{{branch}}</info>)');
118-
119-
// Clone the required branch to the local build directory
120-
run('git clone --single-branch --branch {{branch}} {{repository}} '.$buildPath);
121-
writeln('Clone complete');
122-
123-
cd($buildPath);
124-
125-
// Install PHP packages
126-
run('composer install');
127-
128-
// Build site
129-
writeln('Build Design System website');
130-
run('./vendor/bin/design-system');
131-
132-
writeln('Build complete.');
133-
134-
})->local();
135-
136-
desc('Copy static website files to remote server');
137-
task('deploy:update_code', function () {
138-
139-
$buildRoot = get('build_root');
140-
$directory = run('basename {{repository}} .git');
141-
142-
writeln("<info>Uploading files to server</info>");
143-
upload($buildRoot.'/'.$directory.'/_dist/', '{{release_path}}');
144-
});
145-
146-
// Add unlock to failed deployment event.
147-
after('deploy:failed', 'deploy:unlock');
148-

design-system-build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Run build commands
4+
source ~/.nvm/nvm.sh && nvm use && npm install && npm run build
45
mkdir -p _dist/dist/assets
56
cp -r public/dist/assets/. _dist/dist/assets/
67

design-system-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'Styles' => '/styles/',
1818
'Layouts' => '/layouts/',
1919
'Components' => '/components/',
20-
'Scripts' => '/scripts/',
20+
'Scripts' => '/scripts/',
2121
'Templates' => '/templates/',
2222
],
2323
'templates_path' => 'design-system-templates',

design-system.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@
1616

1717
* https://staging-design-system.w3.org/
1818

19+
## Directory structure
20+
21+
Files used in the Design system website:
22+
23+
```
24+
.github/workflows - GitHub actions to deploy assets to cdn.w3.org
25+
assets-src - Design System frontend assets source files
26+
design-system-templates - Design System website templates
27+
docs - Design System website page content
28+
public - Design System document root
29+
```
30+
31+
Files used in the Symfony template bundle:
32+
33+
```
34+
.github/workflows - GitHub actions to deploy assets to cdn.w3.org
35+
assets-src - Design System frontend assets source files
36+
config - Symfony bundle config
37+
src - Symfony bundle PHP code
38+
templates - Symfony bundle templates
39+
translations - Symfony bundle translation files
40+
```
41+
42+
Please note the HTML templates are duplicated across `design-system-templates` (for the Design System website) and
43+
`templates` (the templates used on w3.org via a Symfony bundle).
44+
45+
Frontend assets for both the Design System and w3.org website are stored in `assets-src`.
46+
1947
## Installing
2048

2149
Install the required libraries via [Composer](https://getcomposer.org/). These are only loaded for local development. Please
@@ -25,6 +53,20 @@ note this requires PHP 7.4+
2553
composer install
2654
```
2755

56+
### Deployment setup
57+
To deploy the website you need to add the following to your `~/.ssh/config` file:
58+
59+
```
60+
Host *.w3.internal
61+
62+
```
63+
64+
You can test this works by:
65+
66+
```
67+
dep ssh staging
68+
```
69+
2870
## Making changes
2971

3072
### Frontend assets

templates/components/styles/notes.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
{% if (notes|length > 0) %}
33
<div class="l-box note note--{{ type }}" role="{{ type == 'error' ? 'alert' : 'status' }}" aria-labelledby="{{ type }}-summary-title" tabindex="-1"
44
data-component="{{ type }}-summary" data-anchor="no">
5-
<h2 id="{{ type }}-summary-title" class="txt-saturn">{{ title }}</h2>
5+
{% if title != '' %}
6+
<h2 id="{{ type }}-summary-title" class="txt-saturn">{{ title }}</h2>
7+
{% endif %}
68
<ul class="clean-list" role="list">
79
{% for note in notes %}
810
<li>
@@ -33,7 +35,7 @@
3335
{% endmacro %}
3436

3537
{% macro warnings(messages, title = null) %}
36-
{% if title == null %}
38+
{% if title is same as null %}
3739
{% set title = 'notes.warnings.default_title'|trans({}, 'w3c_website_templates_bundle') %}
3840
{% endif %}
3941
{{ _self.notes('warning', title, messages) }}

0 commit comments

Comments
 (0)