-
Notifications
You must be signed in to change notification settings - Fork 134
76 lines (73 loc) · 2.99 KB
/
closeVote.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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 | "numberOfBallots=" + 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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
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 }}