-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check non-stargazer and give a tip message
- Loading branch information
Showing
8 changed files
with
1,759 additions
and
1,618 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,48 +22,31 @@ | |
"eslint --fix" | ||
] | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"repository": "https://github.com/wow-actions/welcome-action", | ||
"license": "MIT", | ||
"author": { | ||
"name": "bubkoo", | ||
"email": "[email protected]" | ||
}, | ||
"contributors": [], | ||
"repository": "https://github.com/wow-actions/welcome-action", | ||
"dependencies": { | ||
"@actions/core": "^1.5.0", | ||
"@actions/github": "^5.0.0", | ||
"lodash.random": "^3.2.0", | ||
"@actions/core": "^1.10.0", | ||
"@actions/github": "^5.1.1", | ||
"mustache": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@types/lodash.random": "^3.2.6", | ||
"@types/mustache": "^4.1.2", | ||
"@types/node": "^16.9.1", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"@vercel/ncc": "^0.31.1", | ||
"devmoji": "^2.3.0", | ||
"eslint": "^7.22.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"husky": "^7.0.2", | ||
"is-ci": "^3.0.0", | ||
"lint-staged": "^11.1.2", | ||
"@bubkoo/commitlint-config": "^1.0.1", | ||
"@bubkoo/eslint-config": "^1.3.0", | ||
"@bubkoo/tsconfig": "^1.1.0", | ||
"@types/mustache": "^4.2.2", | ||
"@types/node": "^18.11.18", | ||
"@vercel/ncc": "^0.36.1", | ||
"eslint": "^8.33.0", | ||
"husky": "^8.0.3", | ||
"is-ci": "^3.0.1", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.4.1", | ||
"pretty-quick": "^3.1.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.4.3" | ||
"prettier": "^2.8.3", | ||
"pretty-quick": "^3.1.3", | ||
"rimraf": "^4.1.2", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,93 @@ | ||
import { Action } from './action' | ||
import * as core from '@actions/core' | ||
import * as github from '@actions/github' | ||
import { addReactions } from './reaction' | ||
import { getOctokit, getComment } from './util' | ||
|
||
Action.run() | ||
async function run(context = github.context) { | ||
core.debug(`event: ${context.eventName}`) | ||
core.debug(`action: ${context.payload.action}`) | ||
|
||
try { | ||
const event = context.eventName | ||
const { action } = context.payload | ||
const { issue } = context.payload | ||
const pr = context.payload.pull_request | ||
const isIssue = event === 'issues' && issue != null | ||
const isPR = | ||
(event === 'pull_request' || event === 'pull_request_target') && | ||
pr != null | ||
|
||
if ((isIssue || isPR) && action === 'opened') { | ||
const comment = | ||
issue != null | ||
? core.getInput('FIRST_ISSUE') || core.getInput('FIRST_ISSUE_COMMENT') | ||
: core.getInput('FIRST_PR') || core.getInput('FIRST_PR_COMMENT') | ||
const reactions = | ||
issue != null | ||
? core.getInput('FIRST_ISSUE_REACTIONS') | ||
: core.getInput('FIRST_PR_REACTIONS') | ||
|
||
if (comment) { | ||
const entity = (issue || pr)! | ||
const author = entity.user.login | ||
const octokit = getOctokit() | ||
const response = await octokit.rest.issues.listForRepo({ | ||
...context.repo, | ||
state: 'all', | ||
creator: author, | ||
}) | ||
|
||
const list = response.data.filter((data) => | ||
issue != null ? !data.pull_request : data.pull_request, | ||
) | ||
|
||
if (list.length === 1) { | ||
const { data } = await octokit.rest.issues.createComment({ | ||
...context.repo, | ||
issue_number: entity.number, | ||
body: await getComment(octokit, comment, { author }), | ||
}) | ||
|
||
if (reactions) { | ||
await addReactions(octokit, data.id, reactions) | ||
} | ||
} | ||
} | ||
} else if (isPR && action === 'closed' && pr != null) { | ||
const comment = | ||
core.getInput('FIRST_PR_MERGED') || | ||
core.getInput('FIRST_PR_MERGED_COMMENT') | ||
const reactions = core.getInput('FIRST_PR_MERGED_REACTIONS') | ||
|
||
if (pr.merged && comment) { | ||
const author = pr.user.login | ||
const { owner, repo } = context.repo | ||
const octokit = getOctokit() | ||
const res = await octokit.rest.search.issuesAndPullRequests({ | ||
q: `is:pr is:merged author:${author} repo:${owner}/${repo}`, | ||
}) | ||
|
||
const merged = res.data.items.filter( | ||
(item) => item.number !== pr.number, | ||
) | ||
|
||
if (merged.length === 0) { | ||
const { data } = await octokit.rest.issues.createComment({ | ||
...context.repo, | ||
issue_number: pr.number, | ||
body: await getComment(octokit, comment, { author }), | ||
}) | ||
|
||
if (reactions) { | ||
await addReactions(octokit, data.id, reactions) | ||
} | ||
} | ||
} | ||
} | ||
} catch (e) { | ||
core.error(e) | ||
core.setFailed(e.message) | ||
} | ||
} | ||
|
||
run() |
Oops, something went wrong.