This repository was archived by the owner on Apr 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathdev-build-index.php
More file actions
166 lines (151 loc) · 4.6 KB
/
Copy pathdev-build-index.php
File metadata and controls
166 lines (151 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php /** @noinspection PhpLanguageLevelInspection */
declare(strict_types=1);
/**
* @file
* This is the index.php script for automated CLI builds on Upsun.
*/
use Platformsh\Cli\Service\Config;
require '../vendor/autoload.php';
$config = new Config();
$appName = $config->get('application.name');
$envPrefix = $config->get('service.env_prefix');
$branch = getenv($envPrefix . 'BRANCH', true);
$treeId = getenv($envPrefix . 'TREE_ID', true);
$pharUrl = getenv('CLI_URL_PATH', true) ?: 'platform.phar';
$pharHash = hash_file('sha256', __DIR__ . '/' . ltrim(getenv('CLI_URL_PATH', true), '/'));
if ($timestamp = getenv('CLI_BUILD_DATE', true)) {
$pharDate = date('c', is_int($timestamp) ? $timestamp : strtotime($timestamp));
} else {
$pharDate = false;
}
if ($config->getWithDefault('application.github_repo', '')) {
$sourceLink = 'https://github.com/' . $config->get('application.github_repo');
$sourceLinkSpecific = $sourceLink;
if ($branch) {
if (strpos($branch, 'pr-') === 0 && is_numeric(substr($branch, 3))) {
$sourceLinkSpecific .= '/pull/' . substr($branch, 3);
} else {
$sourceLinkSpecific .= '/tree/' . rawurlencode($branch);
}
}
} else {
$sourceLink = false;
$sourceLinkSpecific = false;
}
$baseUrl = 'https://' . $_SERVER['HTTP_HOST'];
$installScript = sprintf(
'curl -sfS %s | php -- --dev --manifest %s',
$baseUrl . '/installer',
$baseUrl . '/manifest.json',
);
$revertScript = '';
if ($config->has('application.installer_url')) {
$revertScript = sprintf(
'curl -sfS %s | php',
$config->get('application.installer_url')
);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= htmlspecialchars($appName) ?> | dev build</title>
<style>
html {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
background-color: #eee;
}
h1 {
font-weight: 100;
}
h2 {
font-weight: 400;
}
h1, h2 {
text-align: center;
}
h1 a {
color: inherit !important;
text-decoration: none !important;
}
body {
max-width: 40em;
margin: 3em auto;
}
p {
word-break: break-all;
}
img {
display: block;
margin: 10px auto;
}
code {
font-family: "Courier New", Courier, monospace;
}
.code-block {
display: inline-block;
margin: 5px 0;
padding: 5px;
background-color: #fff;
}
</style>
</head>
<body>
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAABlBMVEUAAADg4ODy8Xj7AAAAAXRSTlMAQObYZgAAAB5JREFUOMtj+I8EPozyRnlU4w1NMJhCcDT+hm2MAQAJBMb6YxK/8wAAAABJRU5ErkJggg=="
alt=""
width="100"
height="100">
<?php if ($sourceLink): ?>
<h1><a href="<?= htmlspecialchars($sourceLink) ?>"><?= htmlspecialchars($appName) ?></a></h1>
<?php else: ?>
<h1><?= htmlspecialchars($appName) ?></h1>
<?php endif; ?>
<h2>Development build</h2>
<?php if ($pharUrl): ?>
<p>
Download: <a href="<?= htmlspecialchars($pharUrl) ?>"><?= htmlspecialchars($pharUrl) ?></a>
</p>
<?php endif; ?>
<?php if ($pharDate): ?>
<p>
Build date: <code><?= htmlspecialchars($pharDate) ?></code>
</p>
<?php endif; ?>
<?php if ($pharHash): ?>
<p>
SHA-256 hash: <code><?= htmlspecialchars($pharHash) ?></code>
</p>
<?php endif; ?>
<?php if ($treeId): ?>
<p>
Tree ID: <code><?= htmlspecialchars($treeId) ?></code>
</p>
<?php endif; ?>
<?php if ($branch): ?>
<p>
Branch: <code><?= htmlspecialchars($branch) ?></code>
</p>
<?php endif; ?>
<?php if ($sourceLinkSpecific): ?>
<p>
Source: <a href="<?= htmlspecialchars($sourceLinkSpecific) ?>"><?= htmlspecialchars($sourceLinkSpecific) ?></a>
</p>
<?php endif; ?>
<?php if ($installScript): ?>
<h3>Testing instructions</h3>
<p>
Install this version with:<br/>
<code class="code-block"><?= htmlspecialchars($installScript) ?></code>
</p>
<?php if ($revertScript): ?>
<p>
Install the stable version again with:<br/>
<code class="code-block"><?= htmlspecialchars($revertScript) ?></code>
</p>
<?php endif; ?>
<?php endif; ?>
</body>
</html>