Skip to content

Commit

Permalink
Merge branch 'test-vale' into test-vale-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Jun 17, 2024
2 parents fd444bd + d9ade0e commit 5e1aea7
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,26 @@ jobs:
- name: Install Vale
uses: errata-ai/vale-action@v2

- name: Install jq
run: sudo apt-get install -y jq

- name: Get changed files
id: changed-files
run: |
BASE_SHA=$(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }})
CHANGED_FILES=$(git diff --name-only $BASE_SHA ${{ github.sha }} -- '*.md')
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "CHANGED_FILES=$(echo \"$CHANGED_FILES\" | jq -R -s -c 'split(\"\n\")[:-1]')" >> $GITHUB_ENV
echo "CHANGED_FILES=$(echo \"$CHANGED_FILES\" | jq -R -s -c 'split(\"\n\")[:-1]')"
echo "CHANGED_FILES in GITHUB_ENV: ${{ env.CHANGED_FILES }}"
- name: Print Changed Files
run: echo $CHANGED_FILES
echo "Changed files: $CHANGED_FILES"
- name: Run Vale on changed files
run: |
mkdir -p original_files corrected_files
for file in ${{ env.CHANGED_FILES }}; do
echo "Running Vale on $file"
vale --output=JSON $file > "vale_output_${file//\//_}.json"
vale --output=edit $file > "vale_output_${file//\//_}_edit.md"
done
echo "Vale outputs:"
ls -l
- name: Apply Vale edits and save originals
run: |
mkdir -p original_files
mkdir -p corrected_files
for file in ${{ env.CHANGED_FILES }}; do
echo "Copying $file to original_files/${file//\//_}.original"
vale --output=JSON "$file" > "vale_output_${file//\//_}.json"
vale --output=edit "$file" > "vale_output_${file//\//_}_edit.md"
cp "$file" "original_files/${file//\//_}.original"
echo "Copying vale_output_${file//\//_}_edit.md to corrected_files/${file//\//_}"
cp "vale_output_${file//\//_}_edit.md" "corrected_files/${file//\//_}"
done
echo "Original files:"
ls -l original_files
echo "Corrected files:"
ls -l corrected_files
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
echo "Vale outputs:"
ls -l
- name: Upload original files
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit 5e1aea7

Please sign in to comment.