1
1
import * as core from '@actions/core'
2
2
import * as fs from 'fs'
3
- import client from 'aws-sdk/clients/codedeploy'
3
+ import CodeDeploy from 'aws-sdk/clients/codedeploy'
4
+ import IAM from 'aws-sdk/clients/iam'
5
+ import STS from 'aws-sdk/clients/sts'
4
6
5
7
async function run ( ) : Promise < void > {
6
8
try {
@@ -15,7 +17,7 @@ async function run(): Promise<void> {
15
17
core . debug ( appspecJson )
16
18
core . debug ( '*** end appspecJson ***' )
17
19
18
- const codeDeploy = new client ( )
20
+ const codeDeploy = new CodeDeploy ( )
19
21
const deployment = await codeDeploy
20
22
. createDeployment ( {
21
23
applicationName : appName ,
@@ -29,10 +31,26 @@ async function run(): Promise<void> {
29
31
} )
30
32
. promise ( )
31
33
core . debug ( `deployment: ${ JSON . stringify ( deployment ) } ` )
34
+
32
35
if ( deployment . deploymentId == null ) {
33
36
core . setFailed ( 'deploymentId should not be null' )
34
37
return
35
38
}
39
+
40
+ const { awsAccountAlias, awsAccountId} = await getAccountInformation ( )
41
+ const region = codeDeploy . config . region
42
+ const linkToLogIn = 'https://awslogin.byu.edu/'
43
+ const linkToDeployment = `https://${ region } .console.aws.amazon.com/codesuite/codedeploy/deployments/${ deployment . deploymentId } ?region=${ region } `
44
+ core . info ( `Started deployment.
45
+
46
+ Deployment ID: ${ deployment . deploymentId }
47
+ AWS Account: ${ awsAccountAlias } (${ awsAccountId } )
48
+ Region: ${ region }
49
+
50
+ To view the progress of this deployment:
51
+ • Log into the ${ awsAccountAlias } AWS account at ${ linkToLogIn }
52
+ • Go to ${ linkToDeployment } ` )
53
+
36
54
await codeDeploy
37
55
. waitFor ( 'deploymentSuccessful' , {
38
56
deploymentId : deployment . deploymentId
@@ -47,3 +65,26 @@ async function run(): Promise<void> {
47
65
}
48
66
49
67
run ( )
68
+
69
+ async function getAccountInformation ( ) : Promise < { awsAccountAlias : string ; awsAccountId : string } > {
70
+ const iam = new IAM ( )
71
+ const sts = new STS ( )
72
+ const [
73
+ {
74
+ AccountAliases : [ awsAccountAlias = '?' ]
75
+ } ,
76
+ { Account : awsAccountId = '?' }
77
+ ] = await Promise . all ( [
78
+ iam
79
+ . listAccountAliases ( )
80
+ . promise ( )
81
+ . catch ( ( ) => {
82
+ return { AccountAliases : [ '?' ] }
83
+ } ) ,
84
+ sts
85
+ . getCallerIdentity ( )
86
+ . promise ( )
87
+ . catch ( ( ) => ( { Account : '?' } ) )
88
+ ] )
89
+ return { awsAccountAlias, awsAccountId}
90
+ }
0 commit comments