@@ -43,7 +43,15 @@ export async function run() {
43
43
projectSlug : string
44
44
projectKey : string
45
45
type : 'pages' | 'worker'
46
- environment : string
46
+ environment : {
47
+ name : string ;
48
+ description : string | null ;
49
+ url : string | null ;
50
+ branch : string | null ;
51
+ branchMatchStrategy : "exact" | "prefix" | "suffix" | null ;
52
+ createdAt : Date ;
53
+ lastDeployedAt : Date | null ;
54
+ }
47
55
} > ( `/ci-cd/token` , {
48
56
headers : {
49
57
Authorization : `Bearer ${ idToken } ` ,
@@ -58,7 +66,7 @@ export async function run() {
58
66
core . setSecret ( projectInfo . accessToken )
59
67
core . debug ( `Retrieved project info ${ JSON . stringify ( projectInfo ) } ` )
60
68
61
- core . info ( `Deploying ${ colors . blueBright ( projectInfo . projectSlug ) } to ${ colors . blueBright ( projectInfo . environment ) } environment...` )
69
+ core . info ( `Deploying ${ colors . blueBright ( projectInfo . projectSlug ) } to ${ colors . blueBright ( projectInfo . environment . name ) } environment...` )
62
70
// #endregion
63
71
64
72
// #region Prepare deployment
@@ -79,12 +87,12 @@ export async function run() {
79
87
core . debug ( 'Preparing deployment...' )
80
88
let deploymentInfo
81
89
try {
82
- let prepareUrl = `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment } /deploy/prepare`
90
+ let prepareUrl = `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment . name } /deploy/prepare`
83
91
let publicFiles , publicManifest
84
92
85
93
if ( isWorkerPreset ) {
86
94
// Workers
87
- prepareUrl = `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment } /deploy/worker/prepare`
95
+ prepareUrl = `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment . name } /deploy/worker/prepare`
88
96
publicFiles = await getWorkerPublicFiles ( storage , pathsToDeploy )
89
97
/**
90
98
* { "/index.html": { hash: "hash", size: 30 }
@@ -197,15 +205,15 @@ export async function run() {
197
205
hubUrl,
198
206
projectKey,
199
207
token : projectInfo . accessToken ,
200
- env : projectInfo . environment ,
208
+ env : projectInfo . environment . name ,
201
209
} )
202
210
203
211
core . debug ( 'Fetching remote migrations...' )
204
212
const remoteMigrations = await fetchRemoteMigrations ( {
205
213
hubUrl,
206
214
projectKey,
207
215
token : projectInfo . accessToken ,
208
- env : projectInfo . environment ,
216
+ env : projectInfo . environment . name ,
209
217
} )
210
218
core . info ( `Found ${ colors . blueBright ( remoteMigrations . length ) } applied database migration${ remoteMigrations . length === 1 ? '' : 's' } ` )
211
219
@@ -226,7 +234,7 @@ export async function run() {
226
234
hubUrl,
227
235
projectKey,
228
236
token : projectInfo . accessToken ,
229
- env : projectInfo . environment ,
237
+ env : projectInfo . environment . name ,
230
238
query,
231
239
} )
232
240
core . info ( `Applied database migration ${ colors . blueBright ( queryName ) } ` )
@@ -265,7 +273,7 @@ export async function run() {
265
273
hubUrl,
266
274
projectKey,
267
275
token : projectInfo . accessToken ,
268
- env : projectInfo . environment ,
276
+ env : projectInfo . environment . name ,
269
277
query
270
278
} )
271
279
core . info ( `Applied database query ${ colors . blueBright ( queryName ) } ` )
@@ -286,7 +294,7 @@ export async function run() {
286
294
287
295
// #region Complete deployment
288
296
core . info ( `Publishing deployment...` )
289
- const deployment = await $api ( `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment } /deploy/${ isWorkerPreset ? 'worker/complete' : 'complete' } ` , {
297
+ const deployment = await $api ( `/teams/${ projectInfo . teamSlug } /projects/${ projectInfo . projectSlug } /${ projectInfo . environment . name } /deploy/${ isWorkerPreset ? 'worker/complete' : 'complete' } ` , {
290
298
method : 'POST' ,
291
299
body : {
292
300
deploymentKey,
@@ -309,8 +317,8 @@ export async function run() {
309
317
// Set outputs
310
318
core . setOutput ( 'deployment-url' , deployment . primaryUrl )
311
319
core . setOutput ( 'branch-url' , deployment . branchUrl )
312
- core . setOutput ( 'environment' , projectInfo . environment )
313
- core . info ( `Deployed to ${ projectInfo . environment } : ${ deployment . url ?? deployment . primaryUrl } ` )
320
+ core . setOutput ( 'environment' , projectInfo . environment . name )
321
+ core . info ( `Deployed to ${ projectInfo . environment . name } : ${ deployment . url ?? deployment . primaryUrl } ` )
314
322
// #endregion
315
323
}
316
324
catch ( error ) {
0 commit comments