Skip to content

Commit dae55a1

Browse files
authored
Merge pull request #252 from andrewgy8/claude/github-actions-link-submit-Lsqrt
2 parents 862ec41 + 5e4861e commit dae55a1

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Submit Game from HN Link
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
hn-url:
7+
description: 'Hacker News thread URL (e.g. https://news.ycombinator.com/item?id=12345678)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
submit:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
issues: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Create game submission issue
24+
run: node scripts/submit-from-hn.mjs "${{ github.event.inputs.hn-url }}"
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/submit-from-hn.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { createInterface } from "node:readline/promises";
1616
// CLI args
1717
// ---------------------------------------------------------------------------
1818

19-
const { values: flags } = parseArgs({
19+
const { values: flags, positionals } = parseArgs({
2020
options: {
2121
"dry-run": { type: "boolean", default: false },
2222
help: { type: "boolean", short: "h", default: false },
@@ -174,7 +174,12 @@ function createIssue(item) {
174174
// ---------------------------------------------------------------------------
175175

176176
async function main() {
177-
const input = await prompt("HN thread URL or ID: ");
177+
// Accept URL/ID as positional argument (for non-interactive use, e.g. GitHub Actions)
178+
let input = positionals[0] || process.env.HN_URL || "";
179+
180+
if (!input) {
181+
input = await prompt("HN thread URL or ID: ");
182+
}
178183

179184
if (!input) {
180185
console.error("No URL provided.");

0 commit comments

Comments
 (0)