@webqit/webflo 0.8.53-0 → 0.8.57-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/services/origins/index.js +12 -11
package/package.json
CHANGED
|
@@ -140,27 +140,28 @@ export async function deploy(Ui, origin, flags = {}, layout = {}) {
|
|
|
140
140
|
*/
|
|
141
141
|
export async function hook(Ui, event, deployCallback, flags = {}, layout = {}) {
|
|
142
142
|
const eventHandler = Webhooks.createEventHandler();
|
|
143
|
-
|
|
143
|
+
console.log('-------------------------event.request.headers', event.request.headers)
|
|
144
|
+
if (event.request.headers.has('user-agent') && event.request.headers.get('user-agent').startsWith('GitHub-Hookshot/')) {
|
|
144
145
|
console.log('-------------------------111111111111111111')
|
|
145
|
-
const
|
|
146
|
-
console.log('-------------------------
|
|
147
|
-
const matches = (await origins.match(
|
|
146
|
+
const payload = await event.request.json();
|
|
147
|
+
console.log('-------------------------payload', payload)
|
|
148
|
+
const matches = (await origins.match(payload.repository.full_name, flags, layout)).filter(o => o.autodeploy);
|
|
148
149
|
console.log('-------------------------matches', matches)
|
|
149
150
|
var deployParams;
|
|
150
151
|
if (!(deployParams = matches[0])) {
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
if (matches.length > 1) {
|
|
154
|
-
throw new Error(`Failed deploy attempt (${
|
|
155
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Multiple deploy settings found.`);
|
|
155
156
|
}
|
|
156
157
|
if (!deployParams.autodeploy_secret) {
|
|
157
|
-
throw new Error(`Failed deploy attempt (${
|
|
158
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): The deploy settings do not contain a secret.`);
|
|
158
159
|
}
|
|
159
|
-
if (!Webhooks.verify(deployParams.autodeploy_secret,
|
|
160
|
-
throw new Error(`Failed deploy attempt (${
|
|
160
|
+
if (!Webhooks.verify(deployParams.autodeploy_secret, payload, event.request.headers['x-hub-signature'])) {
|
|
161
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Signature mismatch.`);
|
|
161
162
|
}
|
|
162
|
-
if (
|
|
163
|
-
throw new Error(`Failed deploy attempt (${
|
|
163
|
+
if (payload.repository.disabled || payload.repository.archived) {
|
|
164
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Repository disabled or archived.`);
|
|
164
165
|
}
|
|
165
166
|
eventHandler.on('push', async ({ name, payload }) => {
|
|
166
167
|
Ui.log('---------------------------');
|
|
@@ -183,7 +184,7 @@ export async function hook(Ui, event, deployCallback, flags = {}, layout = {}) {
|
|
|
183
184
|
return eventHandler.receive({
|
|
184
185
|
id: event.request.headers['x-github-delivery'],
|
|
185
186
|
name: event.request.headers['x-github-event'],
|
|
186
|
-
payload:
|
|
187
|
+
payload: payload /* JSON object */,
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
}
|