Skip to content

Commit

Permalink
feat(action): add base-url
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszPorowski committed Mar 9, 2024
1 parent ea4eb57 commit 87c4f3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,19 @@ Action returns some basic information. For more details, follow [📤 Outputs](#
## 📥 Inputs
| Name | Required | Type | Default value | Description |
| :-------------: | :------: | :------: | :-----------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: latest |
| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations |
| `files` | false | `string` | *not set* | To lint different workflow files (default searching directory is `.github/workflows`), use comma-separated glob patterns, e.g., `tests/*.yml, tests/*.yaml` |
| `flags` | false | `string` | *not set* | Extra flags to use with `actionlint` |
| `group-result` | false | `bool` | `true` | Use the GitHub log grouping feature for failure actionlint results. |
| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors |
| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) |
| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) |
| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs |
| Name | Required | Type | Default value | Description |
| :-------------: | :------: | :------: | :--------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `version` | false | `string` | `latest` | SemVer version of `actionlint`, recommended to keep default: `latest` |
| `matcher` | false | `bool` | `true` | Use matcher for GitHub annotations. |
| `files` | false | `string` | *not set* | To lint different workflow files (default searching directory is `.github/workflows`), use comma-separated glob patterns, e.g., `tests/*.yml, tests/*.yaml` |
| `flags` | false | `string` | *not set* | Extra flags to use with `actionlint` |
| `group-result` | false | `bool` | `true` | Use the GitHub log grouping feature for failure actionlint results. |
| `fail-on-error` | false | `bool` | `true` | Fail action on `actionlint` errors. |
| `shellcheck` | false | `bool` | `true` | Use `shellcheck` with `actionlint` (and install if it does not exist) |
| `pyflakes` | false | `bool` | `true` | Use `pyflakes` with `actionlint` (and install if it does not exist) |
| `cache` | false | `bool` | `true` | Use GitHub cache for caching binaries for the next runs. |
| `token` | false | `string` | `github.token` | GitHub Token for API authentication. |
| `base-url` | false | `string` | `github.api_url` | GitHub REST API URL to connect to a different GitHub instance. For example, `https://my.github-enterprise-server.com/api/v3` |

## 📤 Outputs

Expand Down
14 changes: 12 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ inputs:
description: GitHub Token
required: false
default: ${{ github.token }}
base-url:
description: GitHub REST API URL
required: false
default: ${{ github.api_url }}
outputs:
version-semver:
description: SemVer version
Expand Down Expand Up @@ -87,6 +91,7 @@ runs:
id: environment
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
base-url: "https://api.github.com"
script: |
// input envs
const { INPUT_TOOL_NAME, INPUT_TOOL_SEMVER, INPUT_REPO_OWNER, INPUT_REPO_NAME, RUNNER_TEMP } = process.env
Expand Down Expand Up @@ -202,10 +207,12 @@ runs:
shell: ${{ (runner.os == 'Windows' && 'pwsh') || 'bash' }}
working-directory: ${{ inputs.working-directory }}

- uses: actions/github-script@v7
- name: Download tool
uses: actions/github-script@v7
if: ${{ steps.tool-cache.outputs.cache-hit != 'true' }}
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
base-url: ${{ inputs.base-url }}
script: |
// dependencies
const tc = require('@actions/tool-cache')
Expand Down Expand Up @@ -243,6 +250,7 @@ runs:
id: tool-dependencies
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
base-url: ${{ inputs.base-url }}
script: |
// input envs
const { INPUT_PYFLAKES, INPUT_SHELLCHECK } = process.env
Expand Down Expand Up @@ -303,10 +311,12 @@ runs:
INPUT_PYFLAKES: ${{ inputs.pyflakes }}
INPUT_SHELLCHECK: ${{ inputs.shellcheck }}

- uses: actions/github-script@v7
- name: Run tool
uses: actions/github-script@v7
id: tool-runner
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
base-url: ${{ inputs.base-url }}
script: |
// input envs
const { INPUT_FILES, INPUT_FLAGS, INPUT_TOOL_NAME, INPUT_TOOL_DIR_PATH, INPUT_MATCHER, INPUT_MATCHER_PATH, INPUT_TOOL_EXECUTABLE, INPUT_JSON, INPUT_FAIL_ON_ERROR, INPUT_PYFLAKES, INPUT_SHELLCHECK, INPUT_GROUP_RESULT, DEBUG } = process.env
Expand Down

0 comments on commit 87c4f3e

Please sign in to comment.