From a454d96b6dea4d3b81e4680aea4139a45f1ec860 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Wed, 10 Jun 2026 12:51:07 +0000 Subject: [PATCH 1/2] Add GitHub action --- .dockerignore | 1 + action/Dockerfile | 3 +++ action/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ action/action.yml | 30 ++++++++++++++++++++++++++++++ action/entrypoint.sh | 3 +++ 5 files changed, 78 insertions(+) create mode 100644 action/Dockerfile create mode 100644 action/README.md create mode 100644 action/action.yml create mode 100755 action/entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 9c83831..e9a8855 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,7 @@ spec/ .github/ .ruby-lsp/ .vscode/ +action/ .editorconfig .env .env.example diff --git a/action/Dockerfile b/action/Dockerfile new file mode 100644 index 0000000..f845664 --- /dev/null +++ b/action/Dockerfile @@ -0,0 +1,3 @@ +FROM ghcr.io/spenserblack/github-polyglot:v0.1.0-rc.2 +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/action/README.md b/action/README.md new file mode 100644 index 0000000..f302f00 --- /dev/null +++ b/action/README.md @@ -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 +``` diff --git a/action/action.yml b/action/action.yml new file mode 100644 index 0000000..8850156 --- /dev/null +++ b/action/action.yml @@ -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 }} diff --git a/action/entrypoint.sh b/action/entrypoint.sh new file mode 100755 index 0000000..f3ce1db --- /dev/null +++ b/action/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh -l +OUTPUT="$(github-polyglot "$@")" +echo "output=$OUTPUT" >> $GITHUB_OUTPUT From d65a7859021ba6abb9e994de7e6a553ebd6c65a4 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Wed, 10 Jun 2026 12:57:37 +0000 Subject: [PATCH 2/2] Log the output in the action --- action/entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action/entrypoint.sh b/action/entrypoint.sh index f3ce1db..50b50ce 100755 --- a/action/entrypoint.sh +++ b/action/entrypoint.sh @@ -1,3 +1,7 @@ #!/bin/sh -l OUTPUT="$(github-polyglot "$@")" -echo "output=$OUTPUT" >> $GITHUB_OUTPUT +# 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