Skip to content

Commit 948be5e

Browse files
authored
Merge pull request #4 from byu-oit/helpful-logs
Provide logs with links to see run in CodeDeploy
2 parents 7fea4fc + fff3e32 commit 948be5e

File tree

5 files changed

+127
-6
lines changed

5 files changed

+127
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: CI
22
on:
33
pull_request:
44
push:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
![CI](https://github.com/byu-oit/github-action-codedeploy/workflows/CI/badge.svg)
12
![Test](https://github.com/byu-oit/github-action-codedeploy/workflows/Test/badge.svg)
23

34
# ![BYU logo](https://www.hscripts.com/freeimages/logos/university-logos/byu/byu-logo-clipart-128.gif) github-action-codedeploy

dist/index.js

Lines changed: 79 additions & 0 deletions
Large diffs are not rendered by default.

src/index.ts

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as core from '@actions/core'
22
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'
46

57
async 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

4967
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+
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,9 +3262,9 @@ lodash.without@^4.4.0:
32623262
integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=
32633263

32643264
lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15:
3265-
version "4.17.15"
3266-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
3267-
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
3265+
version "4.17.19"
3266+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
3267+
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
32683268

32693269
loose-envify@^1.0.0, loose-envify@^1.4.0:
32703270
version "1.4.0"

0 commit comments

Comments
 (0)