Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: branch is undefined #33

Merged
merged 22 commits into from
Apr 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

## [v2.0.1](https://github.com/amondnet/now-deployment/tree/v2.0.1) (2020-02-25)

[Full Changelog](https://github.com/amondnet/now-deployment/compare/v2.0.0...v2.0.1)
[Full Changelog](https://github.com/amondnet/now-deployment/compare/v2...v2.0.1)

**Fixed bugs:**

@@ -24,13 +24,16 @@

**Implemented enhancements:**

- Support for Now CLI v17 [\#24](https://github.com/amondnet/now-deployment/issues/24)
- Do not want to receive comments from action [\#14](https://github.com/amondnet/now-deployment/issues/14)
- Support for Now CLI v17 [\#24](https://github.com/amondnet/now-deployment/issues/24)
- feat: now cli v17, add `NOW\_PROJECT\_ID` and `NOW\_ORG\_ID` env variable [\#26](https://github.com/amondnet/now-deployment/pull/26) ([amondnet](https://github.com/amondnet))

**Closed issues:**
**Fixed bugs:**

- Deploy stalled [\#23](https://github.com/amondnet/now-deployment/issues/23)

**Closed issues:**

- Can I upload the contents of a folder with pre-built assets? [\#22](https://github.com/amondnet/now-deployment/issues/22)
- getting 403 error every time it tries to comment [\#18](https://github.com/amondnet/now-deployment/issues/18)
- Feature: Ability to specify path for --local-config flag [\#16](https://github.com/amondnet/now-deployment/issues/16)
55 changes: 43 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -20,8 +20,41 @@ if (githubToken) {
}

async function run() {
core.debug(`action : ${context.action}`);
core.debug(`ref : ${context.ref}`);
core.debug(`eventName : ${context.eventName}`);
core.debug(`actor : ${context.actor}`);
core.debug(`sha : ${context.sha}`);
core.debug(`workflow : ${context.workflow}`);
let ref = context.ref;
let sha = context.sha;
await setEnv();
const deploymentUrl = await nowDeploy();

let commit = execSync("git log -1 --pretty=format:%B")
.toString()
.trim();
if (github.context.eventName === 'push') {
const pushPayload = github.context.payload;
core.debug(`The head commit is: ${pushPayload.head_commit}`);
} else if ( github.context.eventName === 'pull_request') {
const pullRequestPayload = github.context.payload;
core.debug(`head : ${pullRequestPayload.pull_request.head}`);

ref = pullRequestPayload.pull_request.head.ref;
sha = pullRequestPayload.pull_request.head.sha;
core.debug(`The head ref is: ${pullRequestPayload.pull_request.head.ref}`);
core.debug(`The head sha is: ${pullRequestPayload.pull_request.head.sha}`);

if ( octokit ) {
const { data: commitData } = await octokit.git.getCommit({
...context.repo, commit_sha: sha
});
commit = commitData.message;
core.debug(`The head commit is: ${commit}`);
}
}

const deploymentUrl = await nowDeploy(ref, commit);
if (deploymentUrl) {
core.info("set preview-url output");
core.setOutput("preview-url", deploymentUrl);
@@ -31,10 +64,10 @@ async function run() {
if (githubComment && githubToken) {
if (context.issue.number) {
core.info("this is related issue or pull_request ");
await createCommentOnPullRequest(deploymentCommit, deploymentUrl);
await createCommentOnPullRequest(sha, deploymentUrl);
} else if (context.eventName === "push") {
core.info("this is push event");
await createCommentOnCommit(deploymentCommit, deploymentUrl);
await createCommentOnCommit(sha, deploymentUrl);
}
} else {
core.info("comment : disabled");
@@ -53,11 +86,7 @@ async function setEnv() {
}
}

async function nowDeploy() {
const commit = execSync("git log -1 --pretty=format:%B")
.toString()
.trim();

async function nowDeploy(ref, commit) {
let myOutput = "";
let myError = "";
const options = {};
@@ -99,7 +128,9 @@ async function nowDeploy() {
"-m",
`githubCommitRepo=${context.repo.repo}`,
"-m",
`githubCommitMessage=${commit}`
`githubCommitMessage=${commit}`,
"-m",
`githubCommitRef=${ref}`
],
options
);
@@ -165,15 +196,15 @@ async function createCommentOnPullRequest(deploymentCommit, deploymentUrl) {
return;
}
const commentId = await findPreviousComment(
"Deploy preview for _website_ ready!"
"This pull request is being automatically deployed with"
);

const commentBody = stripIndents`
Deploy preview for _website_ ready!
This pull request is being automatically deployed with [now-deployment](https://github.com/amondnet/now-deployment)

Built with commit ${deploymentCommit}

https://${deploymentUrl}
✅ Preview: ${deploymentUrl}
`;

if (commentId) {
33 changes: 33 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 29 additions & 17 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 32 additions & 2 deletions node_modules/@actions/core/lib/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/core.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading