Skip to content

Various fixes and improvements for the voting tool #44

Various fixes and improvements for the voting tool

Various fixes and improvements for the voting tool #44

Workflow file for this run

name: Validate vote commit and update participation
on:
pull_request:
types: [synchronize]
paths: [votes/**]
concurrency: ${{ github.workflow }}--${{ github.head_ref }}
permissions:
contents: read
pull-requests: write
repository-projects: read
jobs:
validate-commit-and-update-participation:
if: startsWith(github.head_ref, 'votes/')
runs-on: ubuntu-latest
steps:
- name: Compute number of commits in the PR
id: nb-of-commits
run: |
echo "plusOne=$((${{ github.event.pull_request.commits }} + 1))" >> $GITHUB_OUTPUT
echo "minusOne=$((${{ github.event.pull_request.commits }} - 1))" >> $GITHUB_OUTPUT
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: ${{ steps.nb-of-commits.outputs.plusOne }}
persist-credentials: false
- name: Download nodejs/node mailmap file
run:
curl -L https://raw.githubusercontent.com/nodejs/node/main/.mailmap >>
.mailmap
- run: npm install @node-core/caritat
- name: Get PR description
id: desc
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "markdown<<$EOF" >> "$GITHUB_OUTPUT"
gh pr view "${{ github.event.pull_request.html_url }}" --json body --jq '.body' >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- name: Get updated vote status
id: status
run:
echo "prStatus=$(./votes/initiateNewVote/getVoteStatus.mjs)" >>
"$GITHUB_OUTPUT"; cat "$GITHUB_OUTPUT"
env:
SUBPATH: ${{ github.head_ref }}
FIRST_COMMIT_REF: HEAD^2~${{ steps.nb-of-commits.outputs.minusOne }}
LAST_COMMIT_REF: ${{ github.event.after }}
CHECK_COMMITS_AFTER: ${{ github.event.before }}
PR_DESCRIPTION: ${{steps.desc.outputs.markdown}}
- name: Update PR description
run:
gh pr edit "${{ github.event.pull_request.html_url }}" --body "$BODY"
env:
BODY: ${{ fromJSON(steps.status.outputs.prStatus).body }}
GH_TOKEN: ${{ github.token }}
- name: Add comment if some invalid commits were found
if: fromJSON(steps.status.outputs.prStatus).hasFailures
run:
gh pr comment "${{ github.event.pull_request.html_url }}" -b
"$SUMMARY"
env:
GH_TOKEN: ${{ github.token }}
SUMMARY:
${{ fromJSON(steps.status.outputs.prStatus).invalidCommitReason }}
- name: Mark workflow as failed if some invalid commits were found
if: fromJSON(steps.status.outputs.prStatus).hasFailures
run: 'false'