Skip to content

meysam81/submit-hackernews

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Submit HackerNews

GitHub repo size GitHub commit activity GitHub code size in bytes pre-commit.ci status Docker Image Version Docker Image Size

Introduction

A tiny Go CLI that submits links to Hacker News. It logs in with your credentials, reads the anti-CSRF fields off the submit form, and posts the story — handy for automating submissions on a schedule.

It ships three ways: as a GitHub Action, as a container image, and as a static binary.

Usage: GitHub Actions

name: ci

on:
  workflow_dispatch:
    inputs:
      title:
        description: The title of the link to submit.
        required: true
      url:
        description: The URL of the link to submit.
        required: true
      verbose:
        type: boolean
        description: Verbose?
        default: true

jobs:
  submit-hackernews:
    if: github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    steps:
      - name: Submit link to Hacker News
        uses: meysam81/submit-hackernews@v1
        with:
          username: ${{ secrets.HACKERNEWS_USERNAME }}
          password: ${{ secrets.HACKERNEWS_PASSWORD }}
          title: ${{ github.event.inputs.title }}
          url: ${{ github.event.inputs.url }}
          verbose: ${{ github.event.inputs.verbose }}

Usage: Docker

docker run \
  --name submit-hackernews \
  --rm \
  -e "HACKERNEWS_USERNAME=your_username" \
  -e "HACKERNEWS_PASSWORD=your_password" \
  ghcr.io/meysam81/submit-hackernews:v1 \
  -t "This is the title of submission" \
  -u "https://example.com"

Usage: CLI

Download a binary from the releases page, or build from source (see Development), then:

submit-hackernews \
  --username your_username \
  --password your_password \
  --title "This is the title of submission" \
  --url "https://example.com"

Configuration

Every flag has an environment-variable fallback, so the tool works equally well from a shell, a container, or a GitHub Action.

Flag Alias Environment variable Required Description
--title -t HACKERNEWS_TITLE yes Title of the submission.
--url -u HACKERNEWS_URL yes URL of the submission.
--username -U HACKERNEWS_USERNAME yes Hacker News username.
--password -p HACKERNEWS_PASSWORD yes Hacker News password.
--verbose VERBOSE no Enable verbose logging (request/response details).

Development

Requires Go (see go.mod for the version).

go build ./...                 # build
go test -race -count=1 ./...   # test
go vet ./...                   # vet
gofmt -l .                     # format check

Star History

Star History Chart

Sponsor this project

 

Packages

 
 
 

Contributors