[REMOVE] Testing #20
Workflow file for this run
This file contains hidden or 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: Check acknowledgements consistency | |
| on: | |
| pull_request: | |
| paths: | |
| - news/*/acknowledgements.md | |
| push: | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine changed files | |
| id: changed-files | |
| run: | | |
| changedFiles=$(git diff --name-only --diff-filter=ACMR 578d85aee15ab90de1b41d6f8a47cde39f9da2ea HEAD | grep acknowledgements.md$ | xargs) | |
| echo "Changed files: ${changedFiles}" | |
| echo "files=${changedFiles}" >> "$GITHUB_OUTPUT" | |
| - name: Check modified acknowledgements files | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| 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 | |
| } |