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

feat: github comment optional #20

Merged
merged 6 commits into from
Jan 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: github comment optional
amondnet committed Jan 28, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
amondnet Minsu Lee
commit 3fc20101152bbc444d5b2b310e9536ab347c5fa5
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,13 @@ inputs:
description: ''
required: false
default: ''

github-comment:
required: false
default: 'true'
description: 'if you want to comment on pr or commit, set true, default: true'
github-token:
required: true
required: false
description: 'if you want to comment on pr or commit, set token'
github-deployment:
required: false
default: 'false'
31 changes: 22 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const zeitToken = core.getInput('zeit-token')
const zeitTeamId = core.getInput('zeit-team-id')
const nowArgs = core.getInput('now-args')
const githubToken = core.getInput('github-token')
const githubComment = core.getInput('github-comment')
const githubDeployment = core.getInput('github-deployment')
const workingDirectory = core.getInput('working-directory')

@@ -22,16 +23,21 @@ const zeitAPIClient = axios.create({
},
})

const octokit = new github.GitHub(githubToken)
let octokit
if ( githubToken ) {
octokit = new github.GitHub(githubToken)
}

async function run () {
await nowDeploy()
if (context.issue.number) {
core.info('this is related issue or pull_request ')
await createCommentOnPullRequest()
} else if (context.eventName === 'push') {
core.info('this is push event')
await createCommentOnCommit()
if ( githubComment && githubToken ) {
if (context.issue.number) {
core.info('this is related issue or pull_request ')
await createCommentOnPullRequest()
} else if (context.eventName === 'push') {
core.info('this is push event')
await createCommentOnCommit()
}
}
}

@@ -81,6 +87,9 @@ async function nowDeploy () {
}

async function listCommentsForCommit() {
if (!octokit) {
return;
}
const {
data: comments,
} = await octokit.repos.listCommentsForCommit({
@@ -90,7 +99,9 @@ async function listCommentsForCommit() {
}

async function createCommentOnCommit () {

if (!octokit) {
return;
}
const {
data: comments,
} = await octokit.repos.listCommentsForCommit({
@@ -170,7 +181,9 @@ async function createCommentOnCommit () {
}

async function createCommentOnPullRequest () {

if (!octokit) {
return;
}
const {
data: comments,
} = await octokit.issues.listComments({
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"name": "now-deployment",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/amondnet/now-deployment"
},
"author": {
"name": "Minsu Lee",
"email": "[email protected]",
"url": "https://amond.dev"
},
"version": "1.1.0",
"main": "index.js",
"scripts": {
"start": "node ./index.js"