Skip to content

Commit

Permalink
removed the use bot-token to use a unified github-token (#64)
Browse files Browse the repository at this point in the history
* removed the use bot-token to use a unified github-token
* Governance / Kind -> Governance / Kind Label
  • Loading branch information
fuxingloh authored Mar 11, 2021
1 parent 543a6cf commit f450733
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/governance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pull_request:
* `/kind refactor`
* `/kind dependencies`
status:
context: "Governance / Kind"
context: "Governance / Kind Label"
description:
success: Ready for review & merge.
failure: Missing kind label to generate release automatically.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-use.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
with:
# You can use a PAT to post a comment/label so that it shows up as a user instead of github-actions
# Set the user to Triage, full repo scope.
bot-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}
github-token: ${{ secrets.DEFICHAIN_BOT_GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2021 DeFiChain Foundation
Copyright (c) 2021-2021 Fuxing Loh
Copyright (c) DeFiChain Foundation
Copyright (c) DeFiChain OSS Governance Bot Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ jobs:
name: Governance
runs-on: ubuntu-latest
steps:
# Semantic versioning, lock to different version: v1, v1.x or a commit hash.
- uses: DeFiCh/oss-governance-bot@v1
# Semantic versioning, lock to different version: v2, v2.0 or a commit hash.
- uses: DeFiCh/oss-governance-bot@v2
with:
# You can use a PAT to post a comment/label so that it shows up as a user instead of github-actions
# Set the user to Triage, full repo scope.
bot-token: ${{secrets.BOT_PAT}} # optional, default to '${{ github.token }}'
# You can use a PAT to post a comment/label/status so that it shows up as a user instead of github-actions
github-token: ${{secrets.GITHUB_TOKEN}} # optional, default to '${{ github.token }}'
config-path: .github/governance.yml # optional, default to '.github/governance.yml'
```
Expand Down
2 changes: 1 addition & 1 deletion __tests__/ignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('sender', () => {
await expectIgnore(true)
})

it('should ignore bot-token', async () => {
it('should ignore token from bot', async () => {
github.context.eventName = 'issue_comment'
github.context.payload = {
action: 'created',
Expand Down
2 changes: 0 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ beforeEach(() => {
switch (name) {
case 'github-token':
return 'token'
case 'bot-token':
return 'token'
case 'config-path':
return '.github/governance.yml'
default:
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ inputs:
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT) for everything else'
required: false
default: ${{ github.token }}
bot-token:
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT) to post comment as a user'
required: false
default: ${{ github.token }}

runs:
using: 'node12'
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function initClient(

export async function getBotUserId(): Promise<number> {
core.info('github-client: getBotUserId')
const client = initClient(core.getInput('bot-token'))
const client = initClient()
const user = await client.users.getAuthenticated()
return user.data.id
}
Expand All @@ -32,7 +32,7 @@ export async function addLabels(labels: string[]): Promise<void> {
if (!labels.length) return

core.info('github-client: addLabels')
const client = initClient(core.getInput('bot-token'))
const client = initClient()

await client.issues.addLabels({
owner: github.context.repo.owner,
Expand All @@ -46,7 +46,7 @@ export async function removeLabels(labels: string[]): Promise<void> {
if (!labels.length) return

core.info('github-client: removeLabels')
const client = initClient(core.getInput('bot-token'))
const client = initClient()

await Promise.all(
labels.map(name =>
Expand Down Expand Up @@ -108,7 +108,7 @@ function getIssueUserLogin(): string | undefined {
*/
export async function postComment(body: string) {
core.info('github-client: postComment')
const client = initClient(core.getInput('bot-token'))
const client = initClient()

body = body.replace('$AUTHOR', github.context.payload.sender?.login)
body = body.replace('$ISSUE_AUTHOR', getIssueUserLogin()!)
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function assign(assignees: string[]) {
if (!assignees.length) return

core.info('github-client: assign')
const client = initClient(core.getInput('bot-token'))
const client = initClient()

await client.issues.addAssignees({
owner: github.context.repo.owner,
Expand All @@ -152,7 +152,7 @@ export async function requestReviewers(reviewers: string[]) {
if (!reviewers.length) return

core.info('github-client: requestReviewers')
const client = initClient(core.getInput('bot-token'))
const client = initClient()

await client.pulls.requestReviewers({
owner: github.context.repo.owner,
Expand Down
2 changes: 1 addition & 1 deletion src/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function ignoreBot(): boolean {
}

/**
* Ignores if sender is bot-token user
* Ignores if sender is self
*/
async function ignoreSelf(): Promise<boolean> {
const payload = github.context.payload
Expand Down

0 comments on commit f450733

Please sign in to comment.