-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
lib.ts
71 lines (59 loc) · 2.06 KB
/
lib.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {exportVariable, info, setFailed, setOutput} from '@actions/core'
import {ActionInterface, NodeActionInterface, Status} from './constants'
import {deploy, init} from './git'
import {configureSSH} from './ssh'
import {
checkParameters,
extractErrorMessage,
generateFolderPath,
generateRepositoryPath,
generateTokenType
} from './util'
/** Initializes and runs the action.
*
* @param {object} configuration - The action configuration.
*/
export default async function run(
configuration: ActionInterface | NodeActionInterface
): Promise<void> {
let status: Status = Status.RUNNING
try {
info(`
GitHub Pages Deploy Action 🚀
💖 Support: https://github.com/sponsors/JamesIves
📣 Maintained by James Ives: https://jamesiv.es
🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues`)
info('Checking configuration and starting deployment… 🚦')
const settings: ActionInterface = {
...configuration
}
// Defines the repository/folder paths and token types.
// Also verifies that the action has all of the required parameters.
settings.folderPath = generateFolderPath(settings)
checkParameters(settings)
settings.repositoryPath = generateRepositoryPath(settings)
settings.tokenType = generateTokenType(settings)
if (settings.sshKey) {
await configureSSH(settings)
}
await init(settings)
status = await deploy(settings)
} catch (error) {
status = Status.FAILED
setFailed(extractErrorMessage(error))
} finally {
info(
`${
status === Status.FAILED
? 'Deployment failed! ❌'
: status === Status.SUCCESS
? 'Completed deployment successfully! ✅'
: 'There is nothing to commit. Exiting early… 📭'
}`
)
exportVariable('deployment_status', status)
setOutput('deployment-status', status)
}
}