From 1b6dbf876486d7a54b960e8344ab34d4276946d3 Mon Sep 17 00:00:00 2001 From: karfau Date: Wed, 22 Oct 2025 08:06:07 +0200 Subject: [PATCH 1/3] ci: provide composite action and check it using itself By adding `action.yml` to the top level, this repo can be used as an action, without having to know that is uses go under the hood. Of course we eat the dog food: added a job to the github workflow that uses itself as an action to lint the action.yml file. --- .github/workflows/test.yaml | 12 ++++++++++-- action.yml | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 action.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ad65a2c..599ffdd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v5 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v6 with: go-version-file: go.mod - run: go vet ./... @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v5 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v6 with: go-version-file: go.mod # https://github.com/golangci/golangci-lint-action @@ -37,3 +37,11 @@ jobs: with: version: "${{ env.GOLANGCI_LINT_VERSION }}" args: --timeout=5m --tests=false ./... + + action: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v5 + - uses: ./ + with: + actions: 'action.yml' \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2b9a2db --- /dev/null +++ b/action.yml @@ -0,0 +1,22 @@ +name: composite-action-lint + +description: actionlint for composite actions + +inputs: + actions: + description: paths to actions to lint, supports wildcards + default: .github/actions/*/action.yml + required: false + +runs: + using: composite + steps: + - uses: actions/setup-go@v6 + with: + go-version: 'stable' + - name: Install composite-action-lint + run: go install github.com/bettermarks/composite-action-lint/cmd/composite-action-lint@latest + shell: sh + - name: Check composite actions + run: composite-action-lint ${{ inputs.actions }} + shell: sh From 742e802805bf53f6c6b7f09a1afd67c8404cfd5c Mon Sep 17 00:00:00 2001 From: karfau Date: Wed, 22 Oct 2025 08:20:31 +0200 Subject: [PATCH 2/3] docs: add usage example and improve readme --- README.md | 30 +++++++++++++++++++++++++++--- action.yml | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e54eb6f..7e2780e 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ composite-action-lint ===================== -A shallow structural copy of [actionlint][actionlint-repo] but instead for -linting the steps of [composite github actions][composite-action-tutorial] -instead of github workflow files. +A shallow structural copy of [actionlint][actionlint-repo] +but for linting the steps of [composite github actions][composite-action-tutorial] +instead of workflow files. Significant portions of actionlint have been copied verbatim or with minor @@ -12,6 +12,29 @@ changes. The actionlint license is included at [ACTIONLINT_LICENSE.txt](./ACTIONLINT_LICENSE.txt) +## Usage + +### in a workflow + +Keep in mind: if you don't have any composite actions in your repo, you don't need this action. + +```yaml +name: actionlint +on: + pull_request: + paths: + - .github/** + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: bettermarks/composite-action-lint@main + with: + actions: .github/actions/*/action.yml # this is the default value, so it can be omitted +``` + ## Installation Installation requires a working [go][go] toolchain. @@ -26,6 +49,7 @@ Then ensure you have `$(go env GOPATH)/bin` on your `PATH`. Unlike actionlint, composite-action-lint does not search for actions to lint. Pass each action metadata file as an argument to composite-action-lint +If the path does not point to an action file the command will fail. ```shell composite-action-lint path/to-action/action.yml and/another/action.yaml diff --git a/action.yml b/action.yml index 2b9a2db..c160f60 100644 --- a/action.yml +++ b/action.yml @@ -4,7 +4,7 @@ description: actionlint for composite actions inputs: actions: - description: paths to actions to lint, supports wildcards + description: space separated list of paths to actions to lint, supports wildcards default: .github/actions/*/action.yml required: false From 5d3d64a19fdee0377c2962e835b806b052ff1955 Mon Sep 17 00:00:00 2001 From: karfau Date: Wed, 22 Oct 2025 08:33:49 +0200 Subject: [PATCH 3/3] docs: add workflow comment --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 599ffdd..955718d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,6 +42,6 @@ jobs: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v5 - - uses: ./ - with: + - uses: ./ # use the checked out version of this repo as an action + with: # to lint the composite action it provides actions: 'action.yml' \ No newline at end of file