-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (43 loc) · 1.63 KB
/
index.js
File metadata and controls
73 lines (43 loc) · 1.63 KB
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
72
73
const core = require('@actions/core');
const github = require('@actions/github');
const Deployment = require("./utils/Deployment.js")
const ImagesCalculator = require("./utils/ImagesCalculator.js")
const Dispatcher = require("./utils/Dispatcher.js")
async function run(){
//
// We create a context to pass to other parts of the system
//
const ctx = {
github_token: core.getInput("github_token"),
//
// This is the token we use to dispatch
// It is different from the github_token, because we need to trigger another action
// in another repo.
//
token: core.getInput('token'),
state_repo: core.getInput('state_repo'),
image_repository: core.getInput('image_repository'),
owner: github.context.payload.repository.owner.login,
repo: github.context.payload.repository.name,
deployment_file: core.getInput("deployment_file"),
triggered_event: github.context.eventName,
dispatch_event_name: core.getInput("dispatch_event_name"),
actor: github.context.actor,
master_branch: core.getInput("default_branch"),
current_branch: github.context.ref.replace("refs/heads/", ""),
base_folder: core.getInput("base_folder"),
images: (type, flavour) => {
return ImagesCalculator({action_type: type, flavour}, ctx)
}
}
// we process now all changes
const deployment = await loadDeployment(ctx)
const changes = deployment.allActions()
return new Dispatcher({actions: changes, ctx}).dispatch()
}
async function loadDeployment(ctx){
const file = await Deployment.FROM_MAIN(ctx)
core.info( file )
return new Deployment( file ).init()
}
run()