Skip to content

Commit 4b7bb70

Browse files
committed
Updates to run build locally
1 parent ac95201 commit 4b7bb70

File tree

1 file changed

+34
-56
lines changed

1 file changed

+34
-56
lines changed

deploy.php

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,41 @@
22

33
namespace Deployer;
44

5-
require 'recipe/common.php';
6-
require 'vendor/studio24/deployer-recipes/recipe/common.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/default.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+
// Default deployment and HTTP users
22+
set('remote_user', 'studio24');
2623
set('http_user', 'apache');
2724
set('webroot', '');
2825
set('keep_releases', 10);
29-
set('git_tty', true);
30-
set('allow_anonymous_stats', false);
3126

3227
// Folder to help build clean copy of design system site
3328
set('build_root', getenv('HOME') . '/.deployer');
3429

3530
// Default stage - prevents accidental deploying to production with dep deploy
36-
set('default_stage', 'staging');
31+
set('default_selector', 'stage=staging');
32+
3733

3834
/**
39-
* Hosts
35+
* 3. Hosts
4036
*/
4137

38+
localhost('local');
39+
4240
host('production')
4341
->set('labels', ['stage' => 'production'])
4442
->set('hostname', 'proteus.w3.internal')
@@ -53,71 +51,54 @@
5351
->set('deploy_path','/srv/staging-design-system.w3.org')
5452
->set('url', 'https://staging-design-system.w3.org/');
5553

54+
5655
/**
57-
* Deployment task
58-
* The task that will be run when using dep deploy
56+
* 4. Deployment tasks
5957
*/
6058

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
59+
// Overwrite deploy:prepare to build and upload static site
60+
desc('Prepares a new release');
61+
task('deploy:prepare', [
6862
'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',
63+
'deploy:setup',
7764
'deploy:lock',
7865
'deploy:release',
7966
'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'
67+
'deploy:update_code'
8968
]);
9069

70+
9171
// Build tasks
9272
desc('Build Design System website');
9373
task('local:build', function () {
9474

9575
// Set local Deployment directory
9676
$buildRoot = get('build_root');
9777

78+
// Set project root directory for build
79+
$buildPath = $buildRoot.'/'.run('basename {{repository}} .git');
80+
9881
// Create local Deployment directory
99-
if (!file_exists($buildRoot)) {
82+
if (!file_exists($buildPath)) {
10083
writeln('Creating Deployment Directory');
101-
mkdir($buildRoot);
84+
mkdir($buildPath, recursive: true);
10285
} else {
10386
writeln('Deployment Directory exists, skipping');
10487
}
10588

106-
// Set project root directory for build
107-
$buildPath = $buildRoot.'/'.run('basename {{repository}} .git');
108-
10989
// Remove previous local build
110-
if (!file_exists($buildPath)) {
90+
if (!file_exists($buildPath . '/README.md')) {
11191
writeln('No previous build');
11292
} else {
113-
run('rm -rf '.$buildPath);
93+
run(sprintf('rm -rf %s/*', $buildPath));
11494
writeln('Removed previous build');
11595
}
11696

11797
writeln('Cloning Repository (Branch: <info>{{branch}}</info>)');
11898

11999
// Clone the required branch to the local build directory
120-
run('git clone --single-branch --branch {{branch}} {{repository}} '.$buildPath);
100+
//run('git clone --single-branch --branch {{branch}} {{repository}} '.$buildPath);
101+
run(sprintf("git archive {{branch}} | tar -x -f - -C %s 2>&1", $buildPath));
121102
writeln('Clone complete');
122103

123104
cd($buildPath);
@@ -131,7 +112,7 @@
131112

132113
writeln('Build complete.');
133114

134-
})->local();
115+
})>select('local');
135116

136117
desc('Copy static website files to remote server');
137118
task('deploy:update_code', function () {
@@ -143,6 +124,3 @@
143124
upload($buildRoot.'/'.$directory.'/_dist/', '{{release_path}}');
144125
});
145126

146-
// Add unlock to failed deployment event.
147-
after('deploy:failed', 'deploy:unlock');
148-

0 commit comments

Comments
 (0)