Skip to content

Commit

Permalink
use action to get changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeebru committed Jan 17, 2024
1 parent 4ce26d2 commit 8157969
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,21 @@ jobs:
repository: bitwarden/gh-actions
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|yaml)' | tr '\n' ' ')
MODIFIED_EXISTING_WORKFLOWS=""
COUNT=0
for workflow in $MODIFIED_WORKFLOWS; do
if [ -f $workflow ]; then
MODIFIED_EXISTING_WORKFLOWS+=" ${workflow}"
COUNT=$((COUNT+1))
fi
done
echo "count=$COUNT" >> $GITHUB_OUTPUT
echo "modified-workflows=$MODIFIED_EXISTING_WORKFLOWS" >> $GITHUB_OUTPUT
- name: Get changed files
if: steps.changed-workflows.outputs.count != 0
id: changed-files
uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f # v41.0.1
with:
files: .github/workflows/**

- name: Workflow Lint
if: steps.changed-workflows.outputs.count != 0
if: steps.changed-files.outputs.any_changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: bitwarden/gh-actions/lint-workflow@main
with:
workflows: ${{ steps.changed-workflows.outputs.modified-workflows }}

- name: Get changed files
if: steps.changed-workflows.outputs.count != 0
id: changed-files
uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f # v41.0.1
with:
files: .github/workflows/**

- name: Check for pinned versions
if: steps.changed-files.outputs.any_changed == 'true'
shell: bash
Expand Down

0 comments on commit 8157969

Please sign in to comment.