Skip to content

Commit cb5e208

Browse files
authored
Allow deployments to be triggered by workflow_dispatch events (#8)
This change fixes detection of which branch/commit to use when using (manually triggered) `workflow_dispatch` events to run deployment workflows. See #7 for the description of the problem that existed previously.
1 parent f76ac4d commit cb5e208

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

dist/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ exports.createDeployment = async function(applicationName, fullRepositoryName, b
191191
const fullRepositoryName = payload.repository.full_name; // like "Codertocat/Hello-World"
192192

193193
const isPullRequest = payload.pull_request !== undefined;
194-
const commitId = isPullRequest ? payload.pull_request.head.sha : payload.head_commit.id; // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
194+
const commitId = isPullRequest ? payload.pull_request.head.sha : (payload.head_commit ? payload.head_commit.id : github.context.sha); // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
195195
const branchName = isPullRequest ? payload.pull_request.head.ref : payload.ref.replace(/^refs\/heads\//, ''); // like "my/branch_name"
196196

197197
const skipSequenceCheck = core.getBooleanInput('skip-sequence-check');

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
const fullRepositoryName = payload.repository.full_name; // like "Codertocat/Hello-World"
1111

1212
const isPullRequest = payload.pull_request !== undefined;
13-
const commitId = isPullRequest ? payload.pull_request.head.sha : payload.head_commit.id; // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
13+
const commitId = isPullRequest ? payload.pull_request.head.sha : (payload.head_commit ? payload.head_commit.id : github.context.sha); // like "ec26c3e57ca3a959ca5aad62de7213c562f8c821"
1414
const branchName = isPullRequest ? payload.pull_request.head.ref : payload.ref.replace(/^refs\/heads\//, ''); // like "my/branch_name"
1515

1616
const skipSequenceCheck = core.getBooleanInput('skip-sequence-check');

0 commit comments

Comments
 (0)