Skip to content

Commit

Permalink
feat: switch to pipx & add github-token
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszPorowski committed Jul 12, 2024
1 parent ea4eb57 commit 0b47bca
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
# files: .pre-commit-config.yaml

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-symlinks
- id: trailing-whitespace
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
exclude: package-lock.json

- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
rev: v8.18.4
hooks:
- id: gitleaks
args:
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ 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. |
| `github-token` | false | `string` | `github.token` | GitHub Token for API authentication. |

## 📤 Outputs

Expand Down
26 changes: 18 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
---
name: actionlint
description: ✅ Run actionlint for validating your GitHub Actions workflow files.
author: Dariusz Porowski
Expand Down Expand Up @@ -56,6 +57,11 @@ inputs:
description: GitHub Token
required: false
default: ${{ github.token }}
deprecationMessage: Use `github-token` input instead
github-token:
description: GitHub Token
required: false
default: ${{ github.token }}
outputs:
version-semver:
description: SemVer version
Expand Down Expand Up @@ -86,7 +92,7 @@ runs:
uses: actions/github-script@v7
id: environment
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }}
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 +208,11 @@ 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 }}
github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }}
script: |
// dependencies
const tc = require('@actions/tool-cache')
Expand Down Expand Up @@ -242,7 +249,8 @@ runs:
if: ${{ inputs.pyflakes == 'true' || inputs.shellcheck == 'true' }}
id: tool-dependencies
with:
github-token: ${{ inputs.token || env.GITHUB_TOKEN }}
github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }}
# base-url: ${{ inputs.github-api-url }}
script: |
// input envs
const { INPUT_PYFLAKES, INPUT_SHELLCHECK } = process.env
Expand All @@ -268,7 +276,7 @@ runs:
core.debug(`${pyflakesBinary} exists: ${pyflakesExists}`)
if (pyflakesExists === false) {
await exec.exec('python3', ['-m', 'pip', 'install', '--upgrade', 'pyflakes'])
await exec.exec('pipx', ['install', 'pyflakes'])
}
}
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 }}
github-token: ${{ inputs.github-token || inputs.token || env.GITHUB_TOKEN }}
# base-url: ${{ inputs.github-api-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 0b47bca

Please sign in to comment.