Skip to content

Commit

Permalink
*: use generalized getPatch in action.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Apr 29, 2024
1 parent 2c69ad9 commit a7c7d42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
48 changes: 14 additions & 34 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ runs:
with:
script: |
const { default: filterdiff } = await import('${{ github.action_path }}/src/filterdiff.js')
const { default: getPatch } = await import('${{ github.action_path }}/src/getPatch.js')
const { default: getRenovatePatch } = await import('${{ github.action_path }}/src/getRenovatePatch.js')
const { default: getDependabotPatch } = await import('${{ github.action_path }}/src/getDependabotPatch.js')
const { default: getConfig } = await import('${{ github.action_path }}/src/getConfig.js')
const { default: getProperties } = await import('${{ github.action_path }}/src/getProperties.js')
Expand Down Expand Up @@ -136,6 +133,12 @@ runs:
? await import('${{ github.action_path }}/src/subtleSubmitReview.js')
: await import('${{ github.action_path }}/src/submitReview.js')
const { default: getPatch } = (context.payload.pull_request && context.payload.pull_request.user.login === 'renovate[bot]') || context.actor === 'renovate[bot]'
? await import('${{ github.action_path }}/src/getRenovatePatch.js')
: (context.payload.pull_request && context.payload.pull_request.user.login === 'dependabot[bot]') || context.actor === 'dependabot[bot]'
? await import('${{ github.action_path }}/src/getDependabotPatch.js')
: await import('${{ github.action_path }}/src/getPatch.js')
options.key = options.anthropic_api_key || options.openai_api_key
options.models = options.bedrock_aws_iam_role_arn
? options.bedrock_models
Expand All @@ -152,38 +155,15 @@ runs:
console.log(`Using inputs: ${JSON.stringify(inputs)}`)
}
let patch = null
try {
// if the PR is a renovate PR, we need to get the patch from the renovate API
// check if the PR actor is renovate[bot]
if ((context.payload.pull_request && context.payload.pull_request.user.login === 'renovate[bot]') || context.actor === 'renovate[bot]') {
patch = await getRenovatePatch({
owner: options.owner,
repo: options.repo,
prnum: options.prnum,
debug,
github
})
} else if ((context.payload.pull_request && context.payload.pull_request.user.login === 'dependabot[bot]') || context.actor === 'dependabot[bot]') {
patch = await getDependabotPatch({
owner: options.owner,
repo: options.repo,
prnum: options.prnum,
debug,
github
})
} else {
patch = await getPatch({
owner: options.owner,
repo: options.repo,
prnum: options.prnum,
debug,
runIfPrivate: options.run_if_private,
github
})
}
const patch = await getPatch({
owner: options.owner,
repo: options.repo,
prnum: options.prnum,
debug,
runIfPrivate: options.run_if_private,
github
})
const filteredPatch = await filterdiff({
content: patch.body,
Expand Down
1 change: 1 addition & 0 deletions src/getDependabotPatch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// runIfPrivate always ignored since renovate patches are always public
export default async function getDependabotPatch ({
owner, repo, prnum,
githubToken = null,
Expand Down
1 change: 1 addition & 0 deletions src/getRenovatePatch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { markdownToTxt } from 'markdown-to-txt'

// runIfPrivate always ignored since renovate patches are always public
export default async function getRenovatePatch ({
owner, repo, prnum,
githubToken = null,
Expand Down

0 comments on commit a7c7d42

Please sign in to comment.