-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b87b37
commit 309f8c6
Showing
3 changed files
with
71 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = async ({ github, context, inputs, actionPath, core, debug = false }) => { | ||
const { default: sendSlackMessage } = await import(`${actionPath}/src/sendSlackMessage.js`) | ||
const { default: dependabotNudge } = await import(`${actionPath}/src/dependabotNudge.js`) | ||
|
||
let githubToSlack = {} | ||
try { | ||
githubToSlack = JSON.parse(inputs.gh_to_slack_user_map) | ||
} catch (e) { | ||
if (debug) console.log('GH_TO_SLACK_USER_MAP is not valid JSON') | ||
} | ||
|
||
// set minlevel to 'medium' if it's the first Monday of the month, otherwise stick to high or critical issues | ||
let minlevel = 'medium' | ||
const today = new Date() | ||
if (today.getDate() > 7) { | ||
if (debug) { console.log('Not the first Monday of the month!') } | ||
minlevel = 'high' | ||
} | ||
|
||
const messages = await dependabotNudge({ debug, org: context.repo.owner, github, minlevel, githubToSlack }) | ||
|
||
for (const message of messages) { | ||
try { | ||
await sendSlackMessage({ debug, username: 'dependabot', message, channel: '#secops-hotspots', token: inputs.slack_token }) | ||
} catch (error) { | ||
if (debug) { console.log(error) } | ||
} | ||
} | ||
} |
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,36 @@ | ||
name: weekly-dependabot-nudge | ||
description: Weekly Dependabot Nudge | ||
inputs: | ||
github_token: | ||
description: 'GitHub Token' | ||
required: true | ||
slack_token: | ||
description: 'Slack Token' | ||
required: true | ||
gh_to_slack_user_map: | ||
description: 'JSON map of github usernames to slack usernames' | ||
required: false | ||
debug: | ||
description: 'Debug mode' | ||
required: false | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: '20.x' | ||
- id: npm | ||
run: cd ${{ github.action_path }}/../..; npm ci | ||
shell: bash | ||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
env: | ||
DEBUG: ${{ (inputs.debug == 'true' || runner.debug) && 'true' || 'false'}} | ||
with: | ||
github-token: ${{ inputs.github_token }} | ||
script: |- | ||
const actionPath = '${{ github.action_path }}/../../' | ||
const inputs = ${{ toJson(inputs) }} | ||
const script = require('${{ github.action_path }}/action.cjs') | ||
await script({github, context, inputs, actionPath, core, | ||
debug: process.env.DEBUG === 'true'}) |