Skip to content

Commit 74bd994

Browse files
committed
Support dependency review
In order for dependency review to work, we need to compare the github sha for the pull request. This can be read from the context and set it as the GITHUB_SHA env variable when it exists.
1 parent 4141697 commit 74bd994

File tree

3 files changed

+198
-9
lines changed

3 files changed

+198
-9
lines changed

package-lock.json

Lines changed: 187 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
"dependencies": {
2929
"@actions/core": "^1.10.1",
3030
"@actions/exec": "^1.1.0",
31+
"@actions/github": "^6.0.0",
3132
"@actions/io": "^1.1.3"
3233
},
3334
"devDependencies": {
35+
"@octokit/webhooks-types": "^7.3.1",
3436
"@types/node": "^17.0.30",
3537
"@vercel/ncc": "^0.38.1",
3638
"eslint-plugin-github": "^4.9.0",

src/main.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as cli from '@actions/exec'
22
import * as core from '@actions/core'
33
import * as io from '@actions/io'
4+
import * as github from '@actions/github'
45
import * as crypto from 'crypto'
56
import * as fs from 'fs'
67
import * as fsPromises from 'fs/promises'
78
import * as path from 'path'
9+
import type { PullRequestEvent } from '@octokit/webhooks-types'
810

911
async function run(): Promise<void> {
1012
try {
@@ -48,6 +50,13 @@ async function run(): Promise<void> {
4850

4951
const input = { ignoredModules, ignoredConfigs, onResolveFailure }
5052

53+
if (github.context.eventName === 'pull_request') {
54+
core.info('pull request, resetting sha')
55+
const payload = github.context.payload as PullRequestEvent
56+
core.info(`setting sha to: ${payload.pull_request.head.sha}`)
57+
process.env['GITHUB_SHA'] = payload.pull_request.head.sha
58+
}
59+
5160
process.env['GITHUB_TOKEN'] = token
5261
await cli.exec('sbt', ['--batch', `githubSubmitDependencyGraph ${JSON.stringify(input)}`], {
5362
cwd: workingDir,

0 commit comments

Comments
 (0)