Skip to content

.NET tool to post a random GitHub star to Bluesky

License

Notifications You must be signed in to change notification settings

alexmg/Starrysky

Repository files navigation

Starrysky

Logo

License: MIT Nuget Release Please Open in VS Code

Starrysky is a .NET tool that posts a random GitHub star to Bluesky. It helps you share interesting repositories you have starred on GitHub with your Bluesky followers.

Installation

To install Starrysky as a global .NET tool, run the following command:

dotnet tool install --global Starrysky

Usage

To use Starrysky, run the following command:

starrysky [OPTIONS]

Synopsis

starrysky [-h|--help]
    [-t|--token <TOKEN>]
    [--handle <HANDLE>]
    [-p|--password <PASSWORD>]
    [-d|--dry-run {true|false}]
    [-c|--caching {true|false}]
    [-f|--footer {true|false}]
    [--header <HEADER>]

Options

  • -h|--help Prints help information.

  • -t|--token (default: null)

    Token for access to the GitHub API. This can also be set in the Starrysky__GitHubToken environment variable.

  • --handle (default: null)

    Handle of the Bluesky account. This can also be set in the Starrysky__BlueskyHandle environment variable.

  • -p|--password (default: null)

    Password for the Bluesky account. This can also be set in the Starrysky__BlueskyPassword environment variable.

  • -d|--dry-run (default: false)

    Prints the post to the console without posting to Bluesky or saving history.

  • -c|--caching (default: false)

    Enables caching of the starred GitHub repositories retrieved from the GitHub API. This is useful during development and testing if you have a large number of starred repositories. The cached API results are stored in a repos.json file in the working directory.

  • --footer (default: true)

    Include a footer in the post with a link to this project. This is intended to allow others to discover the project and hopefully use it themselves.

  • --header (default: null)

    A custom header to use for the post instead of the standard header text.

GitHub Action

You can run the Starrysky command line tool in a GitHub Action. This is a convenient way of automating your posts without incurring any hosting costs. Here is an example of a workflow that posts a random GitHub star to Bluesky daily:

name: Daily Bluesky Post

on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:
    inputs:
      dryRun:
        required: false
        default: false
        description: "Execute a dry-run that does not post to Bluesky"
        type: boolean

jobs:
  post:
    name: Post to Bluesky
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/[email protected]
        with:
          fetch-depth: 0
          filter: tree:0

      - name: Setup .NET SDK
        uses: actions/[email protected]
        with:
          dotnet-version: '9.0.x'

      - name: Install global tool
        run: dotnet tool install --global Starrysky

      - name: Execute global tool
        run: >-
          starrysky
          --token ${{ secrets.GH_TOKEN }}
          --handle ${{ secrets.BLUESKY_HANDLE }}
          --password ${{ secrets.BLUESKY_PASSWORD }}
          --dry-run ${{ inputs.dryRun }}

To use this workflow ensure that you have added secrets to your repository for the GH_TOKEN, BLUESKY_HANDLE, and BLUESKY_PASSWORD.

For the GH_TOKEN secret use a fine-grained token and ensure its access is restricted to the repository containing the GitHub workflow.

Repository permissions:

  • Read access to metadata
  • Read and Write access to code

User permissions:

  • Read access to starring

These are permissions are required to query the GitHub API for your starred repositories and to commit the history.json file containing a list of repositories that have been posted to Bluesky.

You can generate a Bluesky App Password for the BLUESKY_PASSWORD secret.

Update the cron expression to a time (UTC) that works best for your target audience.

The workflow includes the workflow_dispatch event to allow for manual triggering from the GitHub frontend. When triggering a manual run of the workflow an input is provided to optionally perform a dry-run.

Credits

Icon made by meaicon from www.flaticon.com

About

.NET tool to post a random GitHub star to Bluesky

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages