fix(devops): fix action name #17
Workflow file for this run
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
name: PR Watcher | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
check-pr-size: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
env: | |
MAX_PR_SIZE: 500 | |
GLOB: "['**/*.md', '**/*.yml', '**/*.json']" | |
with: | |
script: | | |
const MAX_PR_SIZE = parseInt(process.env.MAX_PR_SIZE); | |
const pr = context.payload.pull_request; | |
const changedFiles = await github.rest.pulls.listFiles({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr.number | |
}); | |
const globber = await glob.create(process.env.GLOB, { followSymbolicLinks: false }); | |
const filesAfterGlob = await globber.glob() | |
core.notice(`Files after glob: ${filesAfterGlob}`); | |
const totalAdditions = changedFiles.data.reduce((acc, file) => { | |
if (filesAfterGlob.includes(file.filename)) | |
return acc + file.additions; | |
return 0; | |
}, 0); | |
if (totalAdditions > MAX_PR_SIZE) { | |
github.rest.issues.createComment({ | |
issue_number: pr.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `:x: PR size is too large. Please keep PR size under ${MAX_PR_SIZE} additions.` | |
}); | |
core.setFailed(`PR size is too large. Please keep PR size under ${MAX_PR_SIZE} additions.`); | |
} else { core.notice(`PR size is within limits.`); } |