Skip to content

Commit 91d4e8f

Browse files
authored
Part 1: Logging Improvements (#1022)
* Part 1 of Logging Improvements * Update util.test.ts * Update util.test.ts * Update util.test.ts * Update util.test.ts * Adjustments to tests * Update util.test.ts * Update util.ts
1 parent cdd72ba commit 91d4e8f

9 files changed

Lines changed: 55 additions & 35 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node
22
{
3-
"name": "Node.js & TypeScript",
4-
"build": {
5-
"dockerfile": "Dockerfile",
6-
"args": {
7-
"VARIANT": "14"
8-
}
9-
},
10-
"settings": {
11-
"terminal.integrated.shell.linux": "/bin/bash"
12-
},
13-
"extensions": [
14-
"dbaeumer.vscode-eslint"
15-
],
16-
"remoteUser": "node"
3+
"name": "Node.js & TypeScript",
4+
"build": {
5+
"dockerfile": "Dockerfile",
6+
"args": {
7+
"VARIANT": "14"
8+
}
9+
},
10+
"settings": {
11+
"terminal.integrated.shell.linux": "/bin/bash"
12+
},
13+
"extensions": ["dbaeumer.vscode-eslint"],
14+
"remoteUser": "node"
1715
}

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ jobs:
218218
integration-container,
219219
integration-ssh,
220220
integration-ssh-third-party-client,
221-
integration-env,
221+
integration-env
222222
]
223223
runs-on: ubuntu-latest
224224
steps:

.github/workflows/sponsors.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
file: 'README.md'
1919
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="50px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
2020
maximum: 9999
21-
21+
2222
- name: Generate Sponsors 💖
2323
uses: JamesIves/github-sponsors-readme-action@v1.0.8
2424
with:
@@ -28,7 +28,6 @@ jobs:
2828
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="80px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
2929
marker: 'premium'
3030

31-
3231
- name: Deploy to GitHub Pages
3332
uses: JamesIves/github-pages-deploy-action@v4.2.2
3433
with:

.github/workflows/version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Update Major Version Tag
33
on:
44
push:
55
tags:
6-
- "v*"
6+
- 'v*'
77

88
jobs:
99
update-majorver:

__tests__/env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
process.env.ACTIONS_STEP_DEBUG = 'false'
2+
process.env.RUNNER_OS = 'Windows'

__tests__/main.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ process.env['INPUT_FOLDER'] = 'build'
33
process.env['GITHUB_SHA'] = '123'
44
process.env['INPUT_DEBUG'] = 'debug'
55
process.env['GITHUB_REF_NAME'] = 'test'
6+
process.env['RUNNER_OS'] = 'Linux'
67

78
import '../src/main'
89
import {action, TestFlag} from '../src/constants'
@@ -27,7 +28,8 @@ jest.mock('@actions/core', () => ({
2728
setOutput: jest.fn(),
2829
exportVariable: jest.fn(),
2930
isDebug: jest.fn(),
30-
info: jest.fn()
31+
info: jest.fn(),
32+
notice: jest.fn()
3133
}))
3234

3335
describe('main', () => {

__tests__/util.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('util', () => {
224224
checkParameters(action)
225225
} catch (e) {
226226
expect(e instanceof Error && e.message).toMatch(
227-
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
227+
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
228228
)
229229
}
230230
})
@@ -244,7 +244,7 @@ describe('util', () => {
244244
checkParameters(action)
245245
} catch (e) {
246246
expect(e instanceof Error && e.message).toMatch(
247-
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
247+
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
248248
)
249249
}
250250
})

src/lib.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {exportVariable, info, setFailed, setOutput} from '@actions/core'
1+
import {exportVariable, info, notice, setFailed, setOutput} from '@actions/core'
22
import {ActionInterface, NodeActionInterface, Status} from './constants'
33
import {deploy, init} from './git'
44
import {configureSSH} from './ssh'
@@ -21,8 +21,25 @@ export default async function run(
2121

2222
try {
2323
info(`
24-
GitHub Pages Deploy Action 🚀
24+
╭━━━╮╭╮╭╮╱╭╮╱╱╭╮╱╱╭━━━╮
25+
┃╭━╮┣╯╰┫┃╱┃┃╱╱┃┃╱╱┃╭━╮┃
26+
┃┃╱╰╋╮╭┫╰━╯┣╮╭┫╰━╮┃╰━╯┣━━┳━━┳━━┳━━╮
27+
┃┃╭━╋┫┃┃╭━╮┃┃┃┃╭╮┃┃╭━━┫╭╮┃╭╮┃┃━┫━━┫
28+
┃╰┻━┃┃╰┫┃╱┃┃╰╯┃╰╯┃┃┃╱╱┃╭╮┃╰╯┃┃━╋━━┃
29+
╰━━━┻┻━┻╯╱╰┻━━┻━━╯╰╯╱╱╰╯╰┻━╮┣━━┻━━╯
30+
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
31+
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯
32+
╭━━━╮╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╭━━━╮╱╱╭╮
33+
╰╮╭╮┃╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱┃╭━╮┃╱╭╯╰╮
34+
╱┃┃┃┣━━┳━━┫┃╭━━┳╮╱╭╮┃┃╱┃┣━┻╮╭╋┳━━┳━╮
35+
╱┃┃┃┃┃━┫╭╮┃┃┃╭╮┃┃╱┃┃┃╰━╯┃╭━┫┃┣┫╭╮┃╭╮╮
36+
╭╯╰╯┃┃━┫╰╯┃╰┫╰╯┃╰━╯┃┃╭━╮┃╰━┫╰┫┃╰╯┃┃┃┃
37+
╰━━━┻━━┫╭━┻━┻━━┻━╮╭╯╰╯╱╰┻━━┻━┻┻━━┻╯╰╯
38+
╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╭━╯┃
39+
╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╰━━╯
40+
`)
2541

42+
info(`
2643
💖 Support: https://github.com/sponsors/JamesIves
2744
📣 Maintained by James Ives: https://jamesiv.es
2845
@@ -53,17 +70,19 @@ export default async function run(
5370
status = await deploy(settings)
5471
} catch (error) {
5572
status = Status.FAILED
73+
5674
setFailed(extractErrorMessage(error))
5775
} finally {
58-
info(
59-
`${
60-
status === Status.FAILED
61-
? 'Deployment failed! ❌'
62-
: status === Status.SUCCESS
63-
? 'Completed deployment successfully! ✅'
64-
: 'There is nothing to commit. Exiting early… 📭'
65-
}`
66-
)
76+
const terminationMessage = `${
77+
status === Status.FAILED
78+
? 'Deployment failed! ❌'
79+
: status === Status.SUCCESS
80+
? 'Completed deployment successfully! ✅'
81+
: 'There is nothing to commit. Exiting early… 📭'
82+
}`
83+
84+
info(terminationMessage)
85+
notice(terminationMessage)
6786

6887
exportVariable('deployment_status', status)
6988
setOutput('deployment-status', status)

src/util.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isDebug, info} from '@actions/core'
1+
import {isDebug, warning} from '@actions/core'
22
import {existsSync} from 'fs'
33
import path from 'path'
44
import {
@@ -47,14 +47,15 @@ const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
4747
const nonNullParams = params.filter(
4848
param => !isNullOrUndefined(action[param])
4949
)
50+
5051
return Boolean(nonNullParams.length)
5152
}
5253

5354
/* Verifies the action has the required parameters to run, otherwise throw an error. */
5455
export const checkParameters = (action: ActionInterface): void => {
5556
if (!hasRequiredParameters(action, ['token', 'sshKey'])) {
5657
throw new Error(
57-
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
58+
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
5859
)
5960
}
6061

@@ -77,7 +78,7 @@ export const checkParameters = (action: ActionInterface): void => {
7778
process.env.RUNNER_OS as OperatingSystems
7879
)
7980
) {
80-
info(
81+
warning(
8182
`The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗`
8283
)
8384
}

0 commit comments

Comments
 (0)