Skip to content

Commit

Permalink
github: Add an actionlint github workflow
Browse files Browse the repository at this point in the history
Add a new github actions workflow that will perform linting on github
actions workflow changes. It will only run if github workflows are
modified.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
  • Loading branch information
russellb committed Aug 27, 2024
1 parent 2deb029 commit 71be98b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/actionlint.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Since dependabot cannot update workflows using docker,
# we use this indirection since dependabot can update this file.
FROM docker.io/rhysd/actionlint:1.7.1@sha256:435ecdb63b1169e80ca3e136290072548c07fc4d76a044cf5541021712f8f344
42 changes: 42 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint GitHub Actions workflows
on:
push:
branches:
- "main"
paths:
- '.github/workflows/*.ya?ml'
- '.github/workflows/actionlint.*'
pull_request:
branches:
- "main"
paths:
- '.github/workflows/*.ya?ml'
- '.github/workflows/actionlint.*'

env:
LC_ALL: en_US.UTF-8

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: "Download actionlint"
run: |
docker build --tag actionlint - < .github/workflows/actionlint.dockerfile
- name: "Check workflow files"
run: |
echo "::add-matcher::.github/workflows/matchers/actionlint.json"
docker run --volume="${PWD}:/repo" --workdir=/repo actionlint -color
17 changes: 17 additions & 0 deletions .github/workflows/matchers/actionlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
}
]
}

0 comments on commit 71be98b

Please sign in to comment.