From 44908b773e8ca4f00985f48b389daebe6c08586d Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 19 Apr 2024 08:41:08 -0400 Subject: [PATCH 1/2] Add actionlint workflow Add a workflow for linting github actions configuration. Signed-off-by: Russell Bryant --- .github/mergify.yml | 7 +++++++ .github/workflows/actionlint.yml | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/workflows/actionlint.yml diff --git a/.github/mergify.yml b/.github/mergify.yml index b1432f45..c8a1e276 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -28,6 +28,13 @@ pull_request_rules: - check-success=Shellcheck - check-success=markdown-lint - check-success=DCO + # If files are changed in .github/, the actionlint check must pass + - or: + - and: + # regex should match the one in .github/workflows/actionlint.yml + - files~=.github/.*$ + - check-success=actionlint + - -files~=.github/.*$ actions: merge: method: merge diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 00000000..bbc789f1 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,24 @@ +name: Lint GitHub Actions workflows +on: + push: + branches: ["main"] + paths: + - '.github/**' + pull_request: + branches: ["main"] + paths: + # This regex should match the one used for mergify policy in .github/mergify.yml + - '.github/**' + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Download actionlint + id: get_actionlint + run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + shell: bash + - name: Check workflow files + run: PATH=".:$PATH" make action-lint + shell: bash \ No newline at end of file From c42e9be04080af65f53d553017f0af31a3861d73 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 19 Apr 2024 08:43:50 -0400 Subject: [PATCH 2/2] .github: Address an actionlint warning > .github/workflows/lint-jobs.yml:73:9: shellcheck reported issue in > this script: SC2005:style:1:33: Useless echo? Instead of 'echo > $(cmd)', just use 'cmd' [shellcheck] Signed-off-by: Russell Bryant --- .github/workflows/lint-jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-jobs.yml b/.github/workflows/lint-jobs.yml index d2ce1027..bd20c000 100644 --- a/.github/workflows/lint-jobs.yml +++ b/.github/workflows/lint-jobs.yml @@ -71,4 +71,4 @@ jobs: go-version-file: gobot/go.mod - name: Go Format run: | - [ -z "$(gofmt -l .)" ] || (echo "$(gofmt -l .)" && exit 1) + [ -z "$(gofmt -l .)" ] || (gofmt -l . && exit 1)