Skip to content

Commit

Permalink
Allow deployments to be triggered by workflow_dispatch events (#8)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mkarnicki authored Oct 24, 2021
1 parent f76ac4d commit cb5e208
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ exports.createDeployment = async function(applicationName, fullRepositoryName, b
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 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 skipSequenceCheck = core.getBooleanInput('skip-sequence-check');
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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 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 skipSequenceCheck = core.getBooleanInput('skip-sequence-check');
Expand Down

0 comments on commit cb5e208

Please sign in to comment.