-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcreate-deployment.js
More file actions
30 lines (23 loc) · 1.46 KB
/
create-deployment.js
File metadata and controls
30 lines (23 loc) · 1.46 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
'use strict';
(async function () {
const core = require('@actions/core');
const github = require('@actions/github');
const payload = github.context.payload;
const action = require('./action');
const applicationName = core.getInput('application') || payload.repository.name; // like "Hello-World"
const fullRepositoryName = payload.repository.full_name; // like "Codertocat/Hello-World"
const isPullRequest = payload.pull_request !== undefined;
const commitId = isPullRequest ? payload.pull_request.head.sha : (payload.head_commit ? payload.head_commit.id : github.context.sha); // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
const branchName = isPullRequest ? payload.pull_request.head.ref : payload.ref.replace(/^refs\/heads\//, ''); // like "my/branch_name"
const pullRequestNumber = isPullRequest ? payload.pull_request.number : undefined;
const configLookupName = core.getInput('config-name') || branchName;
const skipSequenceCheck = core.getBooleanInput('skip-sequence-check');
console.log(`🎋 On branch '${branchName}', head commit ${commitId}`);
const runNumber = process.env['github_run_number'] || process.env['GITHUB_RUN_NUMBER'];
try {
await action.createDeployment(applicationName, fullRepositoryName, branchName, pullRequestNumber, configLookupName, commitId, runNumber, skipSequenceCheck, core);
} catch (e) {
console.log(`👉🏻 ${e.message}`);
process.exit(1);
}
})();