Browse Source

Add selective linting to linting workflow (#75)

pull/74/head
mimartin12 3 years ago committed by GitHub
parent
commit
12bf897758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      .github/workflows/workflow-linter.yml
  2. 24
      lint-workflow/action.yml

16
.github/workflows/workflow-linter.yml

@ -13,10 +13,20 @@ jobs: @@ -13,10 +13,20 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Version Branch
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- name: Checkout Branch
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
with:
fetch-depth: 0
- name: Get changed workflows
id: changed-workflows
run: |
MODIFIED_WORKFLOWS=$(git diff --name-only origin/${{ github.base_ref }} | grep -E '.github/workflows/.*.yml' | tr '\n' ' ')
echo "::set-output name=modified-workflows::$MODIFIED_WORKFLOWS"
- name: Workflow Lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: bitwarden/gh-actions/lint-workflow@01cfa748cfdd4983ee7fd134f1f04127a11d907b
uses: bitwarden/gh-actions/lint-workflow@1d934d9ae0adc1d230e00e320c987986467b6498
with:
workflows: ${{ steps.changed-workflows.outputs.modified-workflows }}

24
lint-workflow/action.yml

@ -7,12 +7,26 @@ inputs: @@ -7,12 +7,26 @@ inputs:
runs:
using: "composite"
steps:
- run: pip install --user yamllint
- name: Install dependencies
run: pip install --user yamllint
shell: bash
- run: python ${{ github.action_path }}/lint.py "${{ inputs.workflows }}"
- name: Setup
id: setup
run: |
FORMAT_PATH=$(echo ${{ inputs.workflows }} | sed 's/ *$//')
echo "::set-output name=path::$FORMAT_PATH"
shell: bash
- run: |
TRIM_PATH=$(echo ${{ inputs.workflows }} | tr '\n' ' ')
yamllint -f colored -c ${{ github.action_path }}/.yamllint.yml $TRIM_PATH
- name: Python lint
run: python ${{ github.action_path }}/lint.py "${{ steps.setup.outputs.path }}"
shell: bash
- name: YAML lint
run: |
WORKFLOWS=($(echo "${{ steps.setup.outputs.path }}" | tr ' ' '\n'))
for WORKFLOW in "${WORKFLOWS[@]}"; do
yamllint -f colored -c ${{ github.action_path }}/.yamllint.yml $WORKFLOW
done
shell: bash
working-directory: ${{ github.workspace }}

Loading…
Cancel
Save