-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdeploy.js
More file actions
111 lines (103 loc) · 4.32 KB
/
Copy pathdeploy.js
File metadata and controls
111 lines (103 loc) · 4.32 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
const shell = require('shelljs');
const path = require('path');
const { default: axios } = require('axios');
const args = require('minimist')(process.argv.slice(2));
const databasePath = path.join(__dirname, '../dist/database');
const inAppTutorialsContentPath = path.join(
__dirname,
'../dist/tutorials/in-app'
);
const databaseDestination = `s3://resources.gdevelop-app.com/in-app-tutorials-database`;
const inAppTutorialsDestination = `s3://resources.gdevelop-app.com/in-app-tutorials`;
if (!args['cf-zoneid'] || !args['cf-token']) {
shell.echo(
'❌ You must pass --cf-zoneid, --cf-token to purge the CloudFare cache.'
);
shell.exit(1);
}
{
shell.echo(
'ℹ️ Uploading in app tutorials to resources.gdevelop-app.com/in-app-tutorials...'
);
const output = shell.exec(
`aws s3 sync ${inAppTutorialsContentPath} ${inAppTutorialsDestination} --acl public-read`
);
if (output.code !== 0) {
shell.echo(
'❌ Unable to upload in app tutorials to resources.gdevelop-app.com/in-app-tutorials. Error is:'
);
shell.echo(output.stdout);
shell.echo(output.stderr);
shell.exit(output.code);
}
}
{
shell.echo(
'ℹ️ Uploading database to resources.gdevelop-app.com/in-app-tutorials-database...'
);
const output = shell.exec(
`aws s3 sync ${databasePath} ${databaseDestination} --acl public-read`
);
if (output.code !== 0) {
shell.echo(
'❌ Unable to upload database to resources.gdevelop-app.com/in-app-tutorials-database. Error is:'
);
shell.echo(output.stdout);
shell.echo(output.stderr);
shell.exit(output.code);
}
}
shell.echo('✅ Upload finished');
shell.echo('ℹ️ Purging Cloudflare cache...');
const zoneId = args['cf-zoneid'];
const purgeCacheUrl = `https://api.cloudflare.com/client/v4/zones/${zoneId}/purge_cache`;
axios
.post(
purgeCacheUrl,
{
files: [
// Update the "database"
'https://resources.gdevelop-app.com/in-app-tutorials-database/inAppTutorialShortHeaders.json',
// Update the full tutorials
'https://resources.gdevelop-app.com/in-app-tutorials/flingGame.json',
// Update the guided lessons and their templates.
'https://resources.gdevelop-app.com/in-app-tutorials/plinkoMultiplier.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/plinkoMultiplier/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/cameraParallax.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/cameraParallax/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/healthBar.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/healthBar/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/joystick.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/joystick/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/timer.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/timer/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/object3d.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/object3d/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/knightPlatformer.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/knightPlatformer/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/topDownRPGMovement.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/topDownRPGMovement/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/fireABullet.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/fireABullet/game.json',
'https://resources.gdevelop-app.com/in-app-tutorials/coopPlatformer.json',
'https://resources.gdevelop-app.com/in-app-tutorials/templates/coopPlatformer/game.json',
],
},
{
headers: {
Authorization: `Bearer ${args['cf-token']}`,
'Content-Type': 'application/json',
},
}
)
.then((response) => response.data)
.then(() => {
shell.echo('✅ Cache purge done.');
})
.catch((error) => {
shell.echo(
'❌ Error while requesting cache purge (are your identifiers correct?)'
);
shell.echo(error.message || '(unknown error)');
shell.exit(1);
});