11import * as core from '@actions/core'
22import * 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'
46
57async function run ( ) : Promise < void > {
68 try {
@@ -15,7 +17,7 @@ async function run(): Promise<void> {
1517 core . debug ( appspecJson )
1618 core . debug ( '*** end appspecJson ***' )
1719
18- const codeDeploy = new client ( )
20+ const codeDeploy = new CodeDeploy ( )
1921 const deployment = await codeDeploy
2022 . createDeployment ( {
2123 applicationName : appName ,
@@ -29,10 +31,26 @@ async function run(): Promise<void> {
2931 } )
3032 . promise ( )
3133 core . debug ( `deployment: ${ JSON . stringify ( deployment ) } ` )
34+
3235 if ( deployment . deploymentId == null ) {
3336 core . setFailed ( 'deploymentId should not be null' )
3437 return
3538 }
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+
3654 await codeDeploy
3755 . waitFor ( 'deploymentSuccessful' , {
3856 deploymentId : deployment . deploymentId
@@ -47,3 +65,26 @@ async function run(): Promise<void> {
4765}
4866
4967run ( )
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