Skip to content

Commit

Permalink
create bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-erojaslizano committed May 27, 2024
1 parent a983853 commit 186fc32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,6 @@ jobs:
- name: Run dotnet restore
run: dotnet restore

- name: base SHA
id: base-sha
- name: Run Linter Bash Script
run: |
echo "baseSHA=git merge-base origin/master" >> $GITHUB_OUTPUT
- name: Get all changed files
id: changed-files
env:
BASE_SHA: ${{ steps.base-sha.outputs.baseSHA }}
run: |
echo "changed_files=git diff --name-only $BASE_SHA $GITHUB_SHA" >> $GITHUB_OUTPUT
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
run: |
echo "$ALL_CHANGED_FILES"
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
run: |
for (file in ${ALL_CHANGED_FILES}){
echo "$file was changed"
}
- name: Run dotnet format on changed files
run: |
for file in $ALL_CHANGED_FILES; do
echo "Formatting $file"
dotnet format $file --include $file --verify-no-changes --no-restore
done
bash ci/scripts/linter.sh
18 changes: 18 additions & 0 deletions ci/scripts/linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e
#
# Apply Linter to changed files in PR
current_branch=$(git rev-parse --abbrev-ref HEAD)
BASE_SHA=$(git merge-base master $current_branch)

echo "SHA of the first commit on the current branch '$current_branch': $BASE_SHA"

changed_files=$(git diff --name-only $BASE_SHA HEAD)

echo "all files changed:"
for file in $changed_files; do
echo "$file"
done

echo "Formatting $changed_files"

dotnet format --include $changed_files --verify-no-changes --no-restore

0 comments on commit 186fc32

Please sign in to comment.