Skip to content

Update Acknowledgements for 4.40 #25

Update Acknowledgements for 4.40

Update Acknowledgements for 4.40 #25

name: Check acknowledgements consistency
on:
pull_request:
paths:
- news/*/acknowledgements.md
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Determine changed files
id: changed-files
run: |
changedFiles=$(git diff --name-only --diff-filter=ACMR ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep acknowledgements.md$ | xargs)
echo "Changed files: ${changedFiles}"
echo "files=${changedFiles}" >> "$GITHUB_OUTPUT"
- name: Check modified acknowledgements files
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
id: collect-contributors
with:
script: |
const fs = require('fs')
const files = '${{ steps.changed-files.outputs.files }}'.trim().split(/\s+/)
const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)/]+)\)/g
for (file of files) {
let lines = fs.readFileSync(file, {encoding: 'utf8'}).split(/\r?\n/)
const contributorNames = new Map()
for (line of lines) {
for (match of line.matchAll(nameIdRegex)) {
computeIfAbsent(contributorNames, match.groups.id, () => new Set()).add(match.groups.name)
}
}
for (const [profile, names] of contributorNames) {
if (names.size > 1) {
core.setFailed("Multiple names found for profile '" + profile + "': " + Array.from(names).join(', '))
}
}
}
function computeIfAbsent(map, key, valueSupplier) {
let value = map.get(key)
if (!value) {
value = valueSupplier()
map.set(key, value)
}
return value
}