Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/npm-dependencies-155…
Browse files Browse the repository at this point in the history
…71ecf68
  • Loading branch information
GrantBirki authored May 9, 2024
2 parents 588229b + 2e8e3a1 commit 144653b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions-config-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4

- name: actions-config-validation
uses: GrantBirki/json-yaml-validate@53fae7e7ad5c90e1e232a227a23437ec31e6c75d # pin@v2.6.1
uses: GrantBirki/json-yaml-validate@d7814b94473939c1daaca2c96131b891d4703a3c # pin@v2.7.1
with:
comment: "true" # enable comment mode
yaml_schema: "__tests__/schemas/action.schema.yml"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # [email protected].1
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # [email protected].3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
Expand Down
16 changes: 16 additions & 0 deletions __tests__/functions/prechecks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,22 @@ test('runs prechecks and finds that the user is not an allowed operator', async
message: `### ⚠️ Cannot proceed with operation\n\n> User monalisa is not an allowed operator`,
status: false
})

expect(
await prechecks(
'123',
true,
false, // skip_ci
true, // skip_reviews
false, // allow_drafts
'issue', // contextType
context,
octokit
)
).toStrictEqual({
message: `### ⚠️ Cannot proceed with operation\n\n> User monalisa is not an allowed operator`,
status: false
})
})

test('runs prechecks and finds that skip_ci is set and no reviews are defined', async () => {
Expand Down
12 changes: 6 additions & 6 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.

12 changes: 6 additions & 6 deletions src/functions/prechecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export async function prechecks(
return {message: validPermissionsRes, status: false}
}

// Get allowed operator data
if (!(await isAllowed(context))) {
message = `### ⚠️ Cannot proceed with operation\n\n> User ${context.actor} is not an allowed operator`
return {message: message, status: false}
}

// if this is an issue comment, we can skip all the logic below here as it...
// ... only applies to pull requests
if (contextType === 'issue') {
Expand Down Expand Up @@ -189,12 +195,6 @@ export async function prechecks(
}
}

// Get allowed operator data
if (!(await isAllowed(context))) {
message = `### ⚠️ Cannot proceed with operation\n\n> User ${context.actor} is not an allowed operator`
return {message: message, status: false}
}

// log values for debugging
core.debug('precheck values for debugging:')
core.debug(`reviewDecision: ${reviewDecision}`)
Expand Down

0 comments on commit 144653b

Please sign in to comment.