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..50b50ce --- /dev/null +++ b/action/entrypoint.sh @@ -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