Skip to content

Commit

Permalink
action.*: move comments-before in cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed May 21, 2024
1 parent d61f520 commit 9530fcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 12 additions & 1 deletion action.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ function hashFiles (filename) {
}

module.exports = async ({ github, context, inputs, steps, actionPath, core }) => {
// comments-before steps
let commentsBefore = null
if (steps['reviewdog-enabled-pr'].outputs.result === 'true') {
const actionPath = '${{ github.action_path }}'

const {default: commentsNumber} = await import(`${actionPath}/src/steps/commentsNumber.js`)
const {default: cleanupComments} = await import(`${actionPath}/src/steps/cleanupComments.js`)

const number = await commentsNumber({context, github})
commentsBefore = await cleanupComments({context, github})
}
// unverified-commits steps
let unverifiedCommitsSteps = null
if (steps['reviewdog-enabled-pr'].outputs.result == 'true') {
Expand Down Expand Up @@ -79,7 +90,7 @@ module.exports = async ({ github, context, inputs, steps, actionPath, core }) =>
}
// add should-trigger label step
let shouldTrigger = false
if (steps['reviewdog-enabled-pr'].outputs.result === 'true' && !assigneeRemovedLabel && ((steps['comments-before'].outputs.result !== commentsAfter) || descriptionContainsHotwords)) {
if (steps['reviewdog-enabled-pr'].outputs.result === 'true' && !assigneeRemovedLabel && ((commentsBefore !== commentsAfter) || descriptionContainsHotwords)) {
shouldTrigger = true
}
// add unverified-commits label step
Expand Down
13 changes: 0 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,6 @@ runs:
script: |
const fs = require('fs')
fs.writeFileSync('${{ github.action_path }}/assets/all_changed_files.txt', '${{ steps.changed-files.outputs.all_changed_files }}')
- id: comments-before
if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const actionPath = '${{ github.action_path }}'
const {default: commentsNumber} = await import(`${actionPath}/src/steps/commentsNumber.js`)
const {default: cleanupComments} = await import(`${actionPath}/src/steps/cleanupComments.js`)
const number = await commentsNumber({context, github})
await cleanupComments({context, github})
return number
- if: ${{ steps.reviewdog-enabled.outputs.result == 'true' }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
Expand Down

0 comments on commit 9530fcc

Please sign in to comment.