mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-10 08:20:07 +00:00
style: ๐ lint error
This commit is contained in:
parent
7874cc39cf
commit
6ee941ecc7
6 changed files with 154 additions and 155 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import * as core from '@actions/core'
|
||||
import {GitHub} from '@actions/github/lib/utils'
|
||||
import * as core from "@actions/core"
|
||||
import {GitHub} from "@actions/github/lib/utils"
|
||||
|
||||
function headerComment(header: String): string {
|
||||
return `<!-- Sticky Pull Request Comment${header} -->`
|
||||
|
|
@ -33,7 +33,7 @@ export async function updateComment(
|
|||
previousBody?: string
|
||||
): Promise<void> {
|
||||
if (!body && !previousBody)
|
||||
return core.warning('Comment body cannot be blank')
|
||||
return core.warning("Comment body cannot be blank")
|
||||
|
||||
await octokit.rest.issues.updateComment({
|
||||
...repo,
|
||||
|
|
@ -55,7 +55,7 @@ export async function createComment(
|
|||
previousBody?: string
|
||||
): Promise<void> {
|
||||
if (!body && !previousBody)
|
||||
return core.warning('Comment body cannot be blank')
|
||||
return core.warning("Comment body cannot be blank")
|
||||
|
||||
await octokit.rest.issues.createComment({
|
||||
...repo,
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
import * as core from '@actions/core'
|
||||
import {context} from '@actions/github'
|
||||
import {readFileSync} from 'fs'
|
||||
import * as core from "@actions/core"
|
||||
import {context} from "@actions/github"
|
||||
import {readFileSync} from "fs"
|
||||
|
||||
export const pullRequestNumber =
|
||||
context?.payload?.pull_request?.number ||
|
||||
+core.getInput('number', {required: false})
|
||||
+core.getInput("number", {required: false})
|
||||
|
||||
export const repo = buildRepo()
|
||||
export const header = core.getInput('header', {required: false})
|
||||
export const append = core.getBooleanInput('append', {required: true})
|
||||
export const recreate = core.getBooleanInput('recreate', {required: true})
|
||||
export const deleteOldComment = core.getBooleanInput('delete', {required: true})
|
||||
export const githubToken = core.getInput('GITHUB_TOKEN', {required: true})
|
||||
export const header = core.getInput("header", {required: false})
|
||||
export const append = core.getBooleanInput("append", {required: true})
|
||||
export const recreate = core.getBooleanInput("recreate", {required: true})
|
||||
export const deleteOldComment = core.getBooleanInput("delete", {required: true})
|
||||
export const githubToken = core.getInput("GITHUB_TOKEN", {required: true})
|
||||
|
||||
export const body = buildBody()
|
||||
|
||||
function buildRepo(): {repo: string; owner: string} {
|
||||
return {
|
||||
owner: context.repo.owner,
|
||||
repo: core.getInput('repo', {required: false}) || context.repo.repo
|
||||
repo: core.getInput("repo", {required: false}) || context.repo.repo
|
||||
}
|
||||
}
|
||||
|
||||
function buildBody(): string {
|
||||
const path = core.getInput('path', {required: false})
|
||||
const path = core.getInput("path", {required: false})
|
||||
if (path) {
|
||||
try {
|
||||
return readFileSync(path, 'utf-8')
|
||||
return readFileSync(path, "utf-8")
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
return ''
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
return core.getInput('message', {required: false})
|
||||
return core.getInput("message", {required: false})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
src/main.ts
14
src/main.ts
|
|
@ -1,11 +1,11 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import * as core from "@actions/core"
|
||||
import * as github from "@actions/github"
|
||||
import {
|
||||
findPreviousComment,
|
||||
createComment,
|
||||
updateComment,
|
||||
deleteComment
|
||||
} from './comment'
|
||||
} from "./comment"
|
||||
import {
|
||||
pullRequestNumber,
|
||||
repo,
|
||||
|
|
@ -15,21 +15,21 @@ import {
|
|||
recreate,
|
||||
deleteOldComment,
|
||||
githubToken
|
||||
} from './config'
|
||||
} from "./config"
|
||||
|
||||
async function run(): Promise<undefined> {
|
||||
if (isNaN(pullRequestNumber) || pullRequestNumber < 1) {
|
||||
core.info('no pull request numbers given: skip step')
|
||||
core.info("no pull request numbers given: skip step")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (!deleteOldComment && !body) {
|
||||
throw new Error('Either message or path input is required')
|
||||
throw new Error("Either message or path input is required")
|
||||
}
|
||||
|
||||
if (deleteOldComment && recreate) {
|
||||
throw new Error('delete and recreate cannot be both set to true')
|
||||
throw new Error("delete and recreate cannot be both set to true")
|
||||
}
|
||||
|
||||
const octokit = github.getOctokit(githubToken)
|
||||
|
|
|
|||
Loadingโฆ
Add table
Add a link
Reference in a new issue