forked from sreeteja06/gh-app-labels-and-badges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Remove NO JIRA badge when no JIRA instance has been set, chore:…
… Reformat code, feat: Add workflows
- Loading branch information
1 parent
34c09e3
commit 329f79a
Showing
16 changed files
with
463 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Format | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
- | ||
jobs: | ||
formatting: | ||
name: Code Formatting | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Run Tests | ||
run: npm run test:format |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,41 +1,41 @@ | ||
interface SizeLabelConfig { | ||
lines: number; | ||
lines: number; | ||
} | ||
|
||
interface ConfigFile { | ||
jira_url: string; | ||
pr_size_config: { | ||
xs: SizeLabelConfig; | ||
s: SizeLabelConfig; | ||
m: SizeLabelConfig; | ||
l: SizeLabelConfig; | ||
xl: SizeLabelConfig; | ||
xxl: SizeLabelConfig; | ||
} | ||
release_branch: string; | ||
enable_change_notes: boolean; | ||
jira_url: string; | ||
pr_size_config: { | ||
xs: SizeLabelConfig; | ||
s: SizeLabelConfig; | ||
m: SizeLabelConfig; | ||
l: SizeLabelConfig; | ||
xl: SizeLabelConfig; | ||
xxl: SizeLabelConfig; | ||
}; | ||
release_branch: string; | ||
enable_change_notes: boolean; | ||
} | ||
|
||
export class Config { | ||
readonly jiraUrl: string; | ||
readonly xsSizeLines: number; | ||
readonly sSizeLines: number; | ||
readonly mSizeLines: number; | ||
readonly lSizeLines: number; | ||
readonly xlSizeLines: number; | ||
readonly xxlSizeLines: number; | ||
readonly releaseBranch: string; | ||
readonly enableChangeNotes: boolean; | ||
readonly jiraUrl: string; | ||
readonly xsSizeLines: number; | ||
readonly sSizeLines: number; | ||
readonly mSizeLines: number; | ||
readonly lSizeLines: number; | ||
readonly xlSizeLines: number; | ||
readonly xxlSizeLines: number; | ||
readonly releaseBranch: string; | ||
readonly enableChangeNotes: boolean; | ||
|
||
constructor(configFile: ConfigFile) { | ||
this.jiraUrl = configFile?.jira_url || ''; | ||
this.xsSizeLines = configFile?.pr_size_config?.xs?.lines || 10; | ||
this.sSizeLines = configFile?.pr_size_config?.s?.lines || 30; | ||
this.mSizeLines = configFile?.pr_size_config?.m?.lines || 100; | ||
this.lSizeLines = configFile?.pr_size_config?.l?.lines || 500; | ||
this.xlSizeLines = configFile?.pr_size_config?.xl?.lines || 1000; | ||
this.xxlSizeLines = configFile?.pr_size_config?.xxl?.lines || 10000; | ||
this.releaseBranch = configFile?.release_branch || 'main'; | ||
this.enableChangeNotes = configFile?.enable_change_notes || false; | ||
} | ||
constructor(configFile: ConfigFile) { | ||
this.jiraUrl = configFile?.jira_url || ""; | ||
this.xsSizeLines = configFile?.pr_size_config?.xs?.lines || 10; | ||
this.sSizeLines = configFile?.pr_size_config?.s?.lines || 30; | ||
this.mSizeLines = configFile?.pr_size_config?.m?.lines || 100; | ||
this.lSizeLines = configFile?.pr_size_config?.l?.lines || 500; | ||
this.xlSizeLines = configFile?.pr_size_config?.xl?.lines || 1000; | ||
this.xxlSizeLines = configFile?.pr_size_config?.xxl?.lines || 10000; | ||
this.releaseBranch = configFile?.release_branch || "main"; | ||
this.enableChangeNotes = configFile?.enable_change_notes || false; | ||
} | ||
} |
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,60 +1,64 @@ | ||
import {Probot} from 'probot'; | ||
import { Probot } from "probot"; | ||
import assignPullRequestLabels from "./labels/pull-request-labels"; | ||
import assignReviewLabels from "./labels/review-labels"; | ||
import {createLabelsIfNotExists} from "./labels/label-helpers"; | ||
import {addChangeNotes} from "./summary"; | ||
import {Config} from "./config/config"; | ||
import { createLabelsIfNotExists } from "./labels/label-helpers"; | ||
import { addChangeNotes } from "./summary"; | ||
import { Config } from "./config/config"; | ||
|
||
const preHook = async (context: any): Promise<{ | ||
existingLabels: any; | ||
config: Config; | ||
const preHook = async ( | ||
context: any, | ||
): Promise<{ | ||
existingLabels: any; | ||
config: Config; | ||
}> => { | ||
await createLabelsIfNotExists(context); | ||
const config = await context.config('labels-and-badges.yml'); | ||
return { | ||
existingLabels: await context.octokit.issues.listLabelsOnIssue(context.issue()), | ||
config: new Config(config) | ||
} | ||
} | ||
await createLabelsIfNotExists(context); | ||
const config = await context.config("labels.yml"); | ||
return { | ||
existingLabels: await context.octokit.issues.listLabelsOnIssue( | ||
context.issue(), | ||
), | ||
config: new Config(config), | ||
}; | ||
}; | ||
|
||
const pullRequestHandler = async (context: any, skipChangeNotes: boolean) => { | ||
const {existingLabels, config} = await preHook(context); | ||
await assignPullRequestLabels(context, existingLabels, config); | ||
if (config.enableChangeNotes && !skipChangeNotes) { | ||
await addChangeNotes(context, config); | ||
} | ||
} | ||
const { existingLabels, config } = await preHook(context); | ||
await assignPullRequestLabels(context, existingLabels, config); | ||
if (config.enableChangeNotes && !skipChangeNotes) { | ||
await addChangeNotes(context, config); | ||
} | ||
}; | ||
|
||
export = (app: Probot) => { | ||
app.on('pull_request.opened', async (context) => { | ||
context.log.info('pull_request.opened') | ||
await pullRequestHandler(context, false); | ||
}); | ||
|
||
app.on('pull_request.edited', async (context) => { | ||
context.log.info('pull_request.edited') | ||
await pullRequestHandler(context, true); | ||
}); | ||
|
||
app.on('pull_request.reopened', async (context) => { | ||
context.log.info('pull_request.reopened') | ||
await pullRequestHandler(context, true); | ||
}); | ||
|
||
app.on('pull_request.synchronize', async (context) => { | ||
context.log.info('pull_request.synchronize') | ||
await pullRequestHandler(context, false); | ||
}); | ||
|
||
app.on('pull_request_review.submitted', async (context) => { | ||
context.log.info('pull_request_review.submitted') | ||
const { existingLabels } = await preHook(context); | ||
await assignReviewLabels(context, existingLabels); | ||
}); | ||
|
||
// For more information on building apps: | ||
// https://probot.github.io/docs/ | ||
|
||
// To get your app running against GitHub, see: | ||
// https://probot.github.io/docs/development/ | ||
app.on("pull_request.opened", async (context) => { | ||
context.log.info("pull_request.opened"); | ||
await pullRequestHandler(context, false); | ||
}); | ||
|
||
app.on("pull_request.edited", async (context) => { | ||
context.log.info("pull_request.edited"); | ||
await pullRequestHandler(context, true); | ||
}); | ||
|
||
app.on("pull_request.reopened", async (context) => { | ||
context.log.info("pull_request.reopened"); | ||
await pullRequestHandler(context, true); | ||
}); | ||
|
||
app.on("pull_request.synchronize", async (context) => { | ||
context.log.info("pull_request.synchronize"); | ||
await pullRequestHandler(context, false); | ||
}); | ||
|
||
app.on("pull_request_review.submitted", async (context) => { | ||
context.log.info("pull_request_review.submitted"); | ||
const { existingLabels } = await preHook(context); | ||
await assignReviewLabels(context, existingLabels); | ||
}); | ||
|
||
// For more information on building apps: | ||
// https://probot.github.io/docs/ | ||
|
||
// To get your app running against GitHub, see: | ||
// https://probot.github.io/docs/development/ | ||
}; |
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,2 +1,2 @@ | ||
export * from './review-labels'; | ||
export * from './pull-request-labels'; | ||
export * from "./review-labels"; | ||
export * from "./pull-request-labels"; |
Oops, something went wrong.