Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/markpatterson27/points-bar

A GitHub action that creates an SVG points bar.
https://github.com/markpatterson27/points-bar

actions assessment autograding feedback points

Last synced: 3 days ago
JSON representation

A GitHub action that creates an SVG points bar.

Awesome Lists containing this project

README

        

# Points Bar Action

[![units-test](https://github.com/markpatterson27/points-bar/actions/workflows/test.yml/badge.svg)](https://github.com/markpatterson27/points-bar/actions/workflows/test.yml)

A GitHub action that creates an SVG points bar.


points bar


points badge points badge reversed

## Usage

```yaml
name: Update Points Bar

on:
push:

jobs:
update:
name: Update points bar
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# create points bar
- name: points bar
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: 'points-bar.svg'

# commit and push points-bar if changed
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add 'points-bar.svg'
git commit -m "Add/Update points bar" || exit 0
git push

```

## Inputs

| Input Name | Required | Default | Description |
|---|---|---|---|
| `points` | yes | | Points string separated with a / slash. |
| `path` | yes | | File path to save the generated SVG to. |
| `type` | no | 'default' | Style of bar to generate. Can be either 'default' or 'badge'. |
| `bar-color` | no | | Color to use for the points bar. |
| `bar-background` | no | | Background color for the points bar. |
| `font-color` | no | | Color to use for text. |
| `label` | no | 'Points' | Text to use for label part of points bar. |
| `width` | no | | Bar/badge width. |
| `reverse` | no | 'false' | Reverse the progress direction of the bar. i.e. Progress bar moves from right to left. |

## Examples

### Default

points bar

```yaml
- name: points bar
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-bar.svg'
```

### Badge

points badge

```yaml
- name: points badge
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-badge.svg'
type: 'badge'
```

### Text and Bar Color

points bar color

```yaml
- name: points bar color
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-bar-color.svg'
bar-color: 'gold'
bar-background: '#115544'
font-color: '#BF5700'
```

### Label

points bar custom label

```yaml
- name: points bar
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-bar-custom-label.svg'
label: 'Score'
```

points badge custom label

```yaml
- name: autograde badge
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-badge-custom-label.svg'
type: 'badge'
label: 'Autograde'
```

### Width

points bar wide

```yaml
- name: points bar
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-bar-wide.svg'
width: 220
```

### Reversed

points badge reversed

```yaml
- name: points badge reversed
uses: markpatterson27/points-bar@v1
with:
points: '25/50'
path: '.github/icons/points-badge-reversed.svg'
type: 'badge'
bar-color: '#11BBCC'
bar-background: '#88BBCC'
reverse: true
```

## GitHub Classroom Use

The points bar was original written to be used with GitHub Classroom's autograding feature to provide grade score feedback to students. To use the points bar with GitHub Classroom, replace (or edit) the `.github/workflow/classroom.yml` workflow file used by Autograding with the following:

```yaml
name: GitHub Classroom Workflow

on:
push:
branches:
- '*'
- '!badges'

jobs:
build:
name: Autograding
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

# add id to action so outputs can be used
- uses: education/autograding@v1
id: autograder
continue-on-error: true

# switch to badges branch
- run: git checkout badges || git checkout -b badges

# create points bar
- name: points bar
uses: markpatterson27/points-bar@v1
with:
points: ${{ steps.autograder.outputs.points }}
path: '.github/badges/points-bar.svg'

# commit and push badges if badges have changed
- name: Commit changes to points bar
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add '.github/badges/points-bar.svg'
git commit -m "Add/Update points bar" || exit 0
git push origin badges
```

To display the points bar, add the following to the top of the assignment README:

```
![Points bar](../../blob/badges/.github/badges/points-bar.svg)
```

If you want to float the points bar to the right, use the following instead:

```html
points bar
```

## Using the Reusable Points Bar Workflow

This repository includes a [reusable workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows) for generating a points bar. The workflow includes steps to commit and push the updated points bar back to the repository.

An example of how to use the reusable workflow:

```yaml
name: My Workflow
on:
push:
branches:
- '*'
- '!status'

jobs:
update-points-bar:
uses: markpatterson27/points-bar/.github/workflows/reusable-workflow.yml@main
permissions:
contents: write
with:
points: '10/20'
path: '.github/activity-icons/points-bar.svg'
type: 'bar'
bar-color: '#4c1'
bar-background: '#555'
font-color: '#aaa'
label: 'Points'
width: '100'
reverse: false
branch: status
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
```

Inputs for the reusable workflow follow the action inputs described above with the following additional inputs:

| Input Name | Required | Default | Description |
|---|---|---|---|
| `branch` | yes | 'main' | Name of branch to commit the points bar to. |
| `token` | yes | | Token with permissions to commit and push updated points bar back to the repository. |

## Alternatives

[Badge Action](https://github.com/emibcn/badge-action) creates a customizable badge with many styling options. Useful if you want a customizable badge and don't need a progress style points bar.