Skip to content

Lint workflow

Lint workflow #465

Workflow file for this run

name: Lint workflow
on:
pull_request:
paths:
- .github/workflows/**
merge_group:
types: [checks_requested]
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- name: Check out branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: ${{ github.repository }}
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Check changed files for workflow changes
id: changed-workflows
run: |
if ${{ github.event_name == 'pull_request' }}; then
changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)
else
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)
fi
count=$(( 0 ))
files_to_lint=""
for file in $changed_files; do
if [[ "$file" == ".github/workflows/"* ]]; then
count=$(( $count + 1 ))
files_to_lint="$files_to_lint $file"
fi
done
echo "Workflow files changed: $count"
echo "Files to lint: $files_to_lint"
echo "changed_files=$files_to_lint" >> $GITHUB_OUTPUT
echo "changed_files_count=$count" >> $GITHUB_OUTPUT
- name: Download actionlint configuration
# if: steps.changed-workflows.outputs.changed_files_count != '0'
run: |
curl \
--fail \
--create-dirs \
--output .github/actionlint.yml \
https://raw.githubusercontent.com/bitwarden/workflow-linter/refs/heads/main/.github/actionlint.yml
- name: Set up Python 3.12
# if: steps.changed-workflows.outputs.changed_files_count != '0'
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12.10"
- name: Install bwwl binary
# if: steps.changed-workflows.outputs.changed_files_count != '0'
run: python -m pip install --upgrade bitwarden_workflow_linter
- name: Lint
env:
# files: ${{ steps.changed-workflows.outputs.changed_files }}
WORKFLOW_LIST=$(ls .github/workflows | xargs -I {} echo -n ".github/workflows/{} ")

Check failure on line 71 in .github/workflows/workflow-linter.yml

View workflow run for this annotation

GitHub Actions / Lint workflow

Invalid workflow file

The workflow is not valid. .github/workflows/workflow-linter.yml (Line: 71, Col: 11): Unexpected value 'WORKFLOW_LIST=$(ls .github/workflows | xargs -I {} echo -n ".github/workflows/{} ")' .github/workflows/workflow-linter.yml: Input string was not in a correct format. Failure to parse near offset 133. Expected an ASCII digit.
# if: steps.changed-workflows.outputs.changed_files_count != '0'
run: |
echo $WORKFLOW_LIST
bwwl lint -f $WORKFLOW_LIST