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: Add filter by ecosystem #184

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
# microsoft_teams_webhook: ${{ secrets.MICROSOFT_TEAMS_WEBHOOK }}
# slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
# severity: low,medium
# ecosystem: npm,rubygems
# count: 20
# pager_duty_integration_key: ${{ secrets.PAGER_DUTY_INTEGRATION_KEY }}
# zenduty_api_key: ${{ secrets.ZENDUTY_API_KEY }}
Expand Down
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ inputs:
default: 20
severity:
description: 'Comma separated list of severities. E.g. low,medium,high,critical (NO SPACES BETWEEN COMMA AND SEVERITY)'
ecosystem:
description: "A comma-separated list of ecosystems. If specified, only alerts for these ecosystems will be returned."
branding:
icon: 'alert-octagon'
color: 'red'
Expand Down
6 changes: 4 additions & 2 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.

2 changes: 2 additions & 0 deletions src/fetch-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const fetchAlerts = async (
repositoryName: string,
repositoryOwner: string,
severity: string,
ecosystem: string,
count: number,
): Promise<Alert[] | []> => {
const octokit = new Octokit({
Expand All @@ -20,6 +21,7 @@ export const fetchAlerts = async (
repo: repositoryName,
state: 'open',
severity,
ecosystem,
per_page: count,
})
const alerts: Alert[] = response.data.map((dependabotAlert) =>
Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ async function run(): Promise<void> {
const emailTransportSmtpPassword = getInput('email_transport_smtp_password')
const count = parseInt(getInput('count'))
const severity = getInput('severity')
const ecosystem = getInput('ecosystem')
const { owner } = context.repo
const { repo } = context.repo
const alerts = await fetchAlerts(token, repo, owner, severity, count)
const alerts = await fetchAlerts(
token,
repo,
owner,
severity,
ecosystem,
count,
)
if (alerts.length > 0) {
if (microsoftTeamsWebhookUrl) {
await sendAlertsToMicrosoftTeams(microsoftTeamsWebhookUrl, alerts)
Expand Down