Skip to content

Close vote

Close vote #3

Workflow file for this run

name: Close vote
on:
# Using `issue_comment` is a bit noisy, let's disable it for now.
# issue_comment:
# types: [created]
workflow_dispatch:
inputs:
pr:
description: Vote PR that contains a vote ready to be closed (<number> | <url> | <branch>)
required: true
permissions:
contents: write
pull-requests: write
jobs:
close-vote:
if: github.event.inputs.pr ||
(github.event.issue.pull_request && contains(github.event.comment.body, '-----BEGIN SHAMIR KEY PART-----'))
runs-on: ubuntu-latest
steps:
- name: Get vote PR info
id: pr-info
run: |
gh pr view "$PR_REF" \
-R "$GITHUB_REPOSITORY" \
--json comments,headRefName,commits,url \
--jq '[
(.comments | map(.body | select(contains("-----BEGIN SHAMIR KEY PART-----"))) | "comments=" + tostring),
("head=" + .headRefName),
(.commits | length - 1 | "nbOfBallots=" + tostring),
("URL=" + .url)
] | join("\n")' >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
PR_REF: ${{ github.event.inputs.pr || github.event.issue.number }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Loading the default branch so we use the last version of the mailmap
# rather than getting stuck to when the vote PR was open.
ref: ${{ github.event.repository.default_branch }}
- name: Download nodejs/node mailmap file
run:
curl -L https://raw.githubusercontent.com/nodejs/node/main/.mailmap >>
.mailmap
- name: Fetch vote branch
run: git fetch origin "$BRANCH"
env:
BRANCH: ${{ steps.pr-info.outputs.head }}
- run: npm install --no-save @node-core/caritat
- name: Attempt closing the vote
id: vote-summary
run: |
./votes/initiateNewVote/decryptPrivateKeyAndCloseVote.mjs \
--remote origin --branch "$BRANCH" \
--fromCommit "FETCH_HEAD~${{ steps.pr-info.outputs.numberOfBallots }}" \
--toCommit "FETCH_HEAD" \
--prURL "${{ steps.pr-info.outputs.URL }}" \
--save-markdown-summary summaryComment.md \
--prepare-json-summary-graphql-query createCommitOnBranch.gql --prepare-json-summary-dirname ./votes \
--comments "$COMMENTS"
env:
BRANCH: ${{ steps.pr-info.outputs.head }}
COMMENTS: ${{ steps.pr-info.outputs.comments }}
- name: Push to the PR branch
run: |
cat createCommitOnBranch.gql
gh api graphql -F repo="$GITHUB_REPOSITORY" -F commit_title="close vote and aggregate results" -f query="$(< createCommitOnBranch.gql)"
env:
GH_TOKEN: ${{ github.token }}
- name: Publish vote summary comment
run: |
gh pr comment "${{ steps.pr-info.outputs.URL }}" --body-file summaryComment.md
env:
GH_TOKEN: ${{ github.token }}