Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ spec/
.github/
.ruby-lsp/
.vscode/
action/
.editorconfig
.env
.env.example
Expand Down
3 changes: 3 additions & 0 deletions action/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ghcr.io/spenserblack/github-polyglot:v0.1.0-rc.2
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
41 changes: 41 additions & 0 deletions action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# GitHub Polyglot action

This action runs the `github-polyglot` gem in a Docker container.

## Inputs

### `token`

Optional. GitHub API token to avoid rate limits when scanning repository language details.

### `user`

Optional. The user to collect data for. Defaults to the owner of the repository that is running
the action.

### `format`

Optional. The format of the output. Defaults to `print` (a display format for terminal display).

## Outputs

### `output`

The output of the `github-polyglot` gem.

## Example

```yaml
# ...
steps:
- uses: spenserblack/github-polyglot/action@main
id: github-polyglot
with:
token: ${{ secrets.PAT }}
format: svg
- name: Create language stats image
env:
SVG: ${{ steps.github-polyglot.outputs.output }}
run: echo "$SVG" > language-stats.svg
# Commit the SVG with your favorite commands or actions
```
30 changes: 30 additions & 0 deletions action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: GitHub Polyglot
description: Compile language statistics for a GitHub user
branding:
icon: code
color: orange
inputs:
token:
description: The GitHub token for the API
required: false
user:
description: The user to analyze
required: true
default: ${{ github.repository_owner }}
format:
description: The format of the output
required: true
default: print
outputs:
output:
description: The output of the executable
runs:
using: docker
image: Dockerfile
env:
GITHUB_TOKEN: ${{ inputs.token }}
args:
- "--user"
- ${{ inputs.user }}
- "--format"
- ${{ inputs.format }}
7 changes: 7 additions & 0 deletions action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh -l
OUTPUT="$(github-polyglot "$@")"
# NOTE: We still want to show the output to the user, which can be helpful if the user is using
# the `print` format and just wants to see the output in the action log.
echo -n "$OUTPUT"
# NOTE: Save the output to the `output` output of the action
echo -n "output=$OUTPUT" >> $GITHUB_OUTPUT