[REMOVE] Testing #1
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: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.milestone.description, 'Release') | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.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$) | |
| 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(/\r?\n/) | |
| const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)]+)\)/g | |
| const contributorNames = new Map() | |
| for (file of files) { | |
| let lines = fs.readFileSync(file, {encoding: 'utf8'}).split(/\r?\n/) | |
| for (line of lines) { | |
| for (match of line.matchAll(nameIdRegex)) { | |
| computeIfAbsent(contributorNames, match.groups.id, () => new Set()).add(match.groups.name) | |
| } | |
| } | |
| } | |
| let boolean hasMultipleNames = false | |
| for (const [profile, names] of contributorNames) { | |
| if (names.size > 1) { | |
| core.error('Multiple names found for profile '" + profile + "': ' + Array.from(names).join(', ')) | |
| hasMultipleNames = true | |
| } | |
| } | |
| if (hasMultipleNames) { | |
| throw new Error('No selected name for profile: ' + profile) | |
| } | |
| function computeIfAbsent(map, key, valueSupplier) { | |
| let value = map.get(key) | |
| if (!value) { | |
| value = valueSupplier() | |
| map.set(key, value) | |
| } | |
| return value | |
| } |