You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.4 KiB
75 lines
2.4 KiB
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
|
with: |
|
repository: ${{ github.repository }} |
|
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} |
|
persist-credentials: false |
|
|
|
- name: Check changed files for workflow changes |
|
id: changed-workflows |
|
run: | |
|
if ${{ github.event_name == 'pull_request' }}; then |
|
changed_files=$(git diff --name-only --diff-filter=d -r HEAD^1 HEAD | xargs) |
|
else |
|
changed_files=$(git diff --name-only --diff-filter=d "${{ 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.13 |
|
if: steps.changed-workflows.outputs.changed_files_count != '0' |
|
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
|
with: |
|
python-version: "3.13.7" |
|
|
|
- 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 }} |
|
if: steps.changed-workflows.outputs.changed_files_count != '0' |
|
run: | |
|
echo "$files" |
|
bwwl lint -f $files
|
|
|