-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
27 lines (25 loc) · 1.07 KB
/
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
const core = require('@actions/core');
const { exec } = require('@actions/exec');
const github = require('@actions/github');
try {
const ipAddress = core.getInput('ip-address')
const deploymentPath = core.getInput('deployment-path')
const sshKey = core.getInput('ssh-key')
const username = core.getInput('username')
const now = new Date()
const githubWorkSpace = process.env.GITHUB_WORKSPACE
const deploy = async () => {
exec('source', ['agent-start', `"$GITHUB_ACTION"`])
exec('echo', ["$INPUT_SSH_KEY", 'agent-add'])
await exec('ssh', ['-o', 'StrictHostKeyChecking=no', '-i', sshKey, `${username}@${ipAddress}`, `"mkdir -p ${deploymentPath}"`])
await exec('scp', ['-i', sshKey, '-r', './*', `${username}@${ipAddress}:${deploymentPath}`])
}
deploy()
core.setOutput('deployment-path', deploymentPath)
core.setOutput('deployment-time', now.toISOString())
} catch (error) {
const e = new Error(error)
core.setFailed(`Action failed with message: ${e.message}`)
core.setFailed(e.stack)
core.setFailed(error)
}