Skip to content

Commit e7809a1

Browse files
committed
📝 Update docs + usage
1 parent a9e062a commit e7809a1

File tree

4 files changed

+60
-22
lines changed

4 files changed

+60
-22
lines changed

.github/actions/count-votes/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,22 @@ runs:
103103
markdown=
104104
if [[ -n "${CREATE_MD}" ]]; then
105105
markdown="--md=\"${MD_DIR}\""
106-
mkdir -p ${MD_DIR}
107106
fi
108107
109108
# collect vote results from recently updated issues, prs, discussions
110109
node vote-record-actions/dist/votes.js "${TARGET_DIR}" ${repos} ${remove} ${markdown} ${bot}
111110
112111
git add -A -- "${TARGET_DIR}"
113112
if [[ -n "${CREATE_MD}" ]]; then
113+
# stage markdown results
114114
git add -A -- "${MD_DIR}"
115115
fi
116116
117117
# Regenerate the index if that value is true
118+
# index will reference markdown results (relative paths)
118119
if [ -n "${CREATE_INDEX}" ]; then
119-
mkdir -p $(dirname ${MD_DIR})
120120
node vote-record-actions/dist/genIndex.js "${TARGET_DIR}" "${MD_DIR}" "${INDEX_FILE}"
121+
121122
# Stage the index.
122123
git add -A -- "${INDEX_FILE}"
123124
fi

README.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
11
# Vote Record Actions
22

3-
Common TS Actions that parse/munge vote data stored in issue comments
4-
care of the [haus-rules-bot](https://github.com/commonhaus/automation).
3+
Library/Utility to parse/munge vote data stored in issue comments care of the [haus-rules-bot](https://github.com/commonhaus/automation).
4+
5+
For version in the examples below, use `main` or a published release
6+
7+
## Count votes action
8+
9+
Fine grained action that looks for comments from the specified bot, and creates vote records based on the data in those comments.
10+
It can also (optionally) create a file that lists outstanding/open votes.
11+
12+
```yaml
13+
- name: Count votes
14+
id: count_votes
15+
uses: commonhaus/vote-record-actions/.github/actions/count-votes@<version>
16+
with:
17+
repositories: "commonhaus/foundation"
18+
target_dir: "site/_generated/votes"
19+
branch: "main"
20+
```
21+
22+
## Receive votes workflow
23+
24+
Common workflow for dealing with pushed updates related to votes.
25+
This workflow uses the count-votes action
26+
27+
```yaml
28+
test_votes:
29+
uses: commonhaus/vote-record-actions/.github/workflows/receive-votes.yml@<version>
30+
with:
31+
repositories: "commonhaus-test/automation-test"
32+
vote_comment_bot: "commonhaus-test-bot[bot]"
33+
removeTags: "notice"
34+
target_dir: "votes/raw"
35+
markdown_dir: "votes/results"
36+
index_file: "votes/README.md"
37+
secrets: inherit
38+
```
39+
40+
For version, use `main` or a published release
41+
42+
## Directly with node/TS
43+
44+
"Usage: node vote-record-actions/dist/votes.js [all|recent] jsonDir [--repos=org/repo1,org/repo2] [--md=mdDir] [--removeTag=tag1] --bot=bot-comment-login"
545

646
```bash
747
$ gh repo clone commonhaus/vote-record-actions -- --depth=1
848
$ cd vote-record-actions
949
$ npm ci
50+
$ npm build
1051
1152
# Fetch the results from the bot comment on an issue
12-
$ npm run votes ../votes IC_kwDOKRPTI86LlGLV
53+
$ node ./dist/votes.js "~/votes/raw" --repos="commonhaus/foundation" --md="~/votes/results"
1354
14-
# Update an index that summarizes outstanding actions
15-
$ npm run index ../votes
55+
# Update an index that summarizes outstanding actions (references markdown results)
56+
$ node ./dist/genIndex.js "~/votes/raw" "~/votes/results" "~/votes/README.md"
1657
```
17-
18-
## Reusable workflows
19-
20-
Common workflows for dealing with pushed updates related to votes.
21-
22-
## Reusable actions
23-
24-
Composite actions.

src/genIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { findFiles, makePathRelativeTo } from "./lib/voteRecords";
66

77
const scriptRoot = dirname(import.meta.dirname);
88

9-
const usage = "Usage: npm run genIndex jsonDir mdDir indexFile";
9+
const usage = "Usage: node ./dist/genIndex.js jsonDir mdDir indexFile";
1010

1111
const args = process.argv.slice(2);
1212
if (args.length < 3) {

src/votes.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1+
import { existsSync, mkdirSync } from "node:fs";
12
import type { VoteConfig } from "./@types";
23
import { recordVote } from "./lib/voteRecords";
34
import { queryVotes } from "./lib/voteResults";
45

56
const usage =
6-
"Usage: npm run votes [all|recent] jsonDir [--repos=org/repo1,org/repo2] [--md=mdDir] [--removeTag=tag1]";
7+
"Usage: node ./dist/votes.js [all|recent] jsonDir [--repos=org/repo1,org/repo2] [--md=mdDir] [--removeTag=tag1]";
78

89
const config: VoteConfig = {
910
bot: "haus-rules-bot[bot]",
1011
options: {},
1112
};
1213
for (const arg of process.argv) {
1314
console.log(arg);
14-
if (
15-
arg.endsWith("node") ||
16-
arg.endsWith("npm") ||
17-
arg.endsWith("votes.js")
18-
) {
15+
if (arg.endsWith("votes.js")) {
1916
// skip
2017
} else if (arg.startsWith("--repos=")) {
2118
config.options.repositories = arg.slice(8).split(",");
@@ -41,6 +38,13 @@ if (!config.jsonDir || !config.options.repositories) {
4138
process.exit(1);
4239
}
4340

41+
if (!existsSync(config.jsonDir)) {
42+
mkdirSync(config.jsonDir, { recursive: true });
43+
}
44+
if (!existsSync(config.markdownDir)) {
45+
mkdirSync(config.markdownDir, { recursive: true });
46+
}
47+
4448
const votes = queryVotes(config);
4549
console.log(
4650
"Found",

0 commit comments

Comments
 (0)