-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (25 loc) · 983 Bytes
/
index.js
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
const core = require('@actions/core');
const github = require('@actions/github');
const child_process = require('child_process');
try {
const instanceId = core.getInput('instance-id');
const waitInstanceRunning = core.getBooleanInput('wait-instance-running');
console.log(`Start instance ${instanceId}`);
const output = JSON.parse(child_process
.execSync(`aws ec2 start-instances --instance-ids ${instanceId}`)
.toString());
for (let state of output.StartingInstances) {
const previous = state.PreviousState.Name;
const current = state.CurrentState.Name;
console.log(`Previous state: ${previous}`);
console.log(`Current state: ${current}`);
core.setOutput("previous-state", previous);
core.setOutput("current-state", current);
}
if (waitInstanceRunning) {
console.log(`Wait until the instance is running`);
child_process.execSync(`aws ec2 wait instance-running --instance-ids ${instanceId}`)
}
} catch (error) {
core.setFailed(error.message);
}