Skip to content

A GitHub Action that allows users to connect any number of repos to any number of Beeminder goals based on any combination of events supported by GitHub Actions.

License

Notifications You must be signed in to change notification settings

HaydenMacDonald/multigitminder

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

multigitminder

multigitminder CodeFactor Tutorial

A GitHub Action for logging data points to Beeminder. Configure workflows to trigger on push, pull requests, closed issues, and any other event supported by GitHub Actions.

Rationale

Beeminder's integration with GitHub, gitminder, allows Beeminder users to capture their programming activity as data for their Beeminder goals. Unfortunately, gitminder only tracks commits and issues closed in a single repo or across your whole GitHub account. Conversely, multigitminder allows users to connect any number of repos to any number of Beeminder goals based on any combination of events supported by GitHub Actions.

How it Works

After configuring a workflow file in your chosen repo(s), GitHub Actions will run multigitminder every time your chosen event type occurs. The action uses a simple python script (via pyminder) to push data points to Beeminder's API. Your Beeminder username and auth token are kept safe, since they are stored as secrets in your GitHub repo(s) and obscured by GitHub Actions.

multigitminder flow diagram

Installation

Implement this action on any repo you own by:

  • Creating a workflow file in a .github/workflows/ directory (see examples directory).
  • Specifying your goal parameters in the file (see Inputs section).
  • Storing your Beeminder username and authorization token as secrets in the repo.

Inputs

Required

  • USERNAME - Your Beeminder username, stored as a secret in your repo.
  • AUTH_TOKEN - Your unique authorization token for Beeminder API, stored as a secret in your repo.
  • GOAL - Name of your goal.

Optional

  • VALUE - Value of data point as string (default value of '1').
  • COMMENT - Comment about the data point (default: '[branch]@[commit-ref] via multigitminder API call').
  • TARGET_LANGS - List of target languages, formatted as a stringified array/list (e.g. "['python', 'javascript']")
  • REPO_LANGS - List of languages inputted by fabasoad/setup-enry-action.

Outputs

  • Print statement confirming the value, goal, and comment of data point sent to Beeminder.

Secrets & Environmental Variables

multigitminder requires a Beeminder username and auth token as an input, stored as secrets in your chosen repo(s). For help on how to store a secret in your repo, see the GitHub Docs.

Example Usage

See examples directory.

Log data to a Beeminder goal when pushing to the main branch:

name: multigitminder-push
on:
  push:
    branches: [ main ]

jobs:
  multigitminder:
    runs-on: ubuntu-latest
    name: multigitminder
    steps:
      - name: multigitminder
        uses: HaydenMacDonald/multigitminder@v1.1.0
        with:
          USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
          AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
          GOAL: YOUR_GOAL_NAME_HERE

Log data to a Beeminder goal after pushing or closing an issue:

name: multigitminder-push-issue-closed
on:
  push:
    branches: [ main ]
  issues:
    types: [ closed ]

jobs:
  multigitminder:
    runs-on: ubuntu-latest
    name: multigitminder
    steps:
      - name: multigitminder
        uses: HaydenMacDonald/multigitminder@v1.1.0
        with:
          USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
          AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
          GOAL: YOUR_GOAL_NAME_HERE

See the GitHub Actions documentation for more events that can trigger this action.

What if I want commits to a repo to contribute to multiple Beeminder goals?

Create a workflow file in your repo's .github/workflows/ directory for each goal, changing the input parameters accordingly.

What if I want specific commits to trigger multigitminder?

Add a conditional to your workflow file like so:

name: multigitminder-specific-commits
on:
  push:
    branches: [ main ]

jobs:
  multigitminder:
    if: "contains(github.event.head_commit.message, '[multigitminder]')" ## THIS LINE HERE
    runs-on: ubuntu-latest
    name: multigitminder
    steps:
      - name: multigitminder
        uses: HaydenMacDonald/multigitminder@v1.1.0
        with:
          USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
          AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
          GOAL: YOUR_GOAL_NAME_HERE

and include [multigitminder] in the commit message of the commits you want to count towards your Beeminder goal.

What if I want repositories with specific languages contributing to my Beeminder goal?

Use actions/checkout@v2 and fabasoad/setup-enry-action in the steps preceding multigitminder in your workflow file. Then add setup-enry-action's output data and a list with your target language(s) as inputs for multigitminder (see below).

name: multigitminder-linguist
on:
  push:
    branches: [ main ]

jobs:
  multigitminder:
    runs-on: ubuntu-latest
    name: multigitminder
    steps:
      # Checkout
      - name: Checkout
        uses: actions/checkout@v2
      # Enry
      - name: Setup Enry
        uses: fabasoad/setup-enry-action@v0.1.0
      - name: Run Enry
        id: enry
        run: echo ::set-output name=languages::"{$(enry | sed 's/^\(.*\)\t\(.*\)$/\"\2\":\"\1\"/' | paste -sd "," -)}"
      # multigitminder
      - name: multigitminder
        uses: HaydenMacDonald/multigitminder@v1.1.0
        id: multigitminder
        with:
          USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
          AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
          GOAL: YOUR_GOAL_NAME_HERE
          TARGET_LANGS: YOUR_TARGET_LANGUAGES_HERE ## e.g. "['python', 'dockerfile', 'javascript']" or simply Python
          REPO_LANGS: ${{ steps.enry.outputs.languages }}

What if I want my commit messages to be the comment on the Beeminder data point?

Add ${{ github.event.head_commit.message }} as input for the comment variable.

name: multigitminder-commit-message-comment
on:
  push:
    branches: [ main ]

jobs:
  multigitminder:
    runs-on: ubuntu-latest
    name: multigitminder
    steps:
      - name: multigitminder
        uses: HaydenMacDonald/multigitminder@v1.1.0
        with:
          USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
          AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
          GOAL: YOUR_GOAL_NAME_HERE
          COMMENT: ${{ github.event.head_commit.message }}

License

The scripts and documentation in this project are released under the MIT License

Contributions

Contributions are welcome! See our Code of Conduct.

About

A GitHub Action that allows users to connect any number of repos to any number of Beeminder goals based on any combination of events supported by GitHub Actions.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published