forked from webfactory/create-aws-codedeploy-deployment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
22 lines (17 loc) · 1.06 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
'use strict';
(async function () {
const core = require('@actions/core');
const github = require('@actions/github');
const payload = github.context.payload;
const action = require('./create-deployment');
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.id; // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
const branchName = isPullRequest ? payload.pull_request.head.ref : payload.ref.replace(/^refs\/heads\//, ''); // like "my/branch_name"
console.log(`🎋 On branch '${branchName}', head commit ${commitId}`);
const runNumber = process.env['github_run_number'] || process.env['GITHUB_RUN_NUMBER'];
try {
action.createDeployment(applicationName, fullRepositoryName, branchName, commitId, runNumber, core);
} catch (e) {}
})();