Skip to content

Commit 0013c87

Browse files
committed
feat: add GitHub action interface
1 parent 134853a commit 0013c87

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: submit-hackernews
2+
description: Submit links to Hacker News.
3+
inputs:
4+
username:
5+
description: The username of the Hacker News user.
6+
required: true
7+
password:
8+
description: The password of the Hacker News user.
9+
required: true
10+
title:
11+
description: The title of the link to submit.
12+
required: true
13+
url:
14+
description: The URL of the link to submit.
15+
required: true
16+
verbose:
17+
description: Whether to output verbose logs. Any non-empty value will be considered true.
18+
required: false
19+
default: ""
20+
runs:
21+
using: docker
22+
image: Dockerfile
23+
env:
24+
HACKERNEWS_USERNAME: ${{ inputs.username }}
25+
HACKERNEWS_PASSWORD: ${{ inputs.password }}
26+
HACKERNEWS_TITLE: ${{ inputs.title }}
27+
HACKERNEWS_URL: ${{ inputs.url }}
28+
VERBOSE: ${{ inputs.verbose }}

main.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ usage() {
1919
echo "All four arguments MUST be provided."
2020
}
2121

22+
set_verbosity() {
23+
set +u
24+
25+
if [ ! -z "$VERBOSE" ]; then
26+
set -x
27+
fi
28+
29+
set -u
30+
}
31+
2232
prepare_cookie() {
2333
COOKIE_JAR=$(mktemp)
2434
}
@@ -162,6 +172,8 @@ submit() {
162172
}
163173

164174
main() {
175+
set_verbosity
176+
165177
parse_args "$@"
166178
parse_envs
167179
validate_args

0 commit comments

Comments
 (0)