From 0b47bcaf4fc120c2bc1318db13b39450de2cbe12 Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:37:36 -0700 Subject: [PATCH] feat: switch to pipx & add github-token --- .pre-commit-config.yaml | 4 ++-- README.md | 23 ++++++++++++----------- action.yml | 26 ++++++++++++++++++-------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30df3b0..04286a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/README.md b/README.md index fe80b0b..6c80363 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index a2c597c..3dc0cff 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 @@ -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 @@ -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') @@ -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 @@ -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']) } } @@ -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