diff --git a/.github/workflows/vale.yml b/.github/workflows/vale.yml index 85903a3a9fd..efb4d8ae498 100644 --- a/.github/workflows/vale.yml +++ b/.github/workflows/vale.yml @@ -1,4 +1,4 @@ -name: Lint and suggest +name: Lint and Suggest on: pull_request: @@ -10,20 +10,19 @@ permissions: pull-requests: write jobs: - vale: # Vale linting job + vale: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: - fetch-depth: 0 # Fetch all history so we can access all commits + fetch-depth: 0 - name: Install Vale uses: errata-ai/vale-action@v2 - - - name: Install jq - run: sudo apt-get install -y jq + with: + version: latest - name: Get changed files id: changed-files @@ -31,27 +30,25 @@ jobs: 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 "::set-output name=files::$(echo $CHANGED_FILES | jq -R -s -c 'split(\"\\n\")[:-1]')" - name: Print Changed Files run: echo $CHANGED_FILES - name: Run Vale on changed files run: | - for file in ${{ env.CHANGED_FILES }}; do + for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do echo "Running Vale on $file" - vale --output=JSON $file > "vale_output_${file//\//_}.json" - vale --output=edit $file > "vale_output_${file//\//_}_edit.md" + vale --output=JSON "$file" > "vale_output_${file//\//_}.json" done echo "Vale outputs:" ls -l - - name: Simulate Vale changes + - name: Apply Vale suggestions run: | - mkdir -p simulated_changes + mkdir -p suggested_changes for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do - cp "$file" "simulated_changes/$(basename "$file")" - vale --output=edit "simulated_changes/$(basename "$file")" + vale --output=line "$file" | grep -oP 'Consider changing.*' > suggested_changes/"$(basename "$file")".suggestions done - name: Upload Vale results @@ -60,27 +57,27 @@ jobs: name: vale-results path: '*.json' - - name: Upload simulated changes + - name: Upload suggested changes uses: actions/upload-artifact@v3 with: - name: simulated-changes - path: simulated_changes + name: suggested-changes + path: suggested_changes/ suggest: runs-on: ubuntu-latest - needs: vale # This ensures the suggest job runs after the vale job + needs: vale steps: - name: Checkout code uses: actions/checkout@v3 - - name: Download simulated changes + - name: Download suggested changes uses: actions/download-artifact@v3 with: - name: simulated-changes + name: suggested-changes - name: List downloaded files - run: ls -l simulated_changes + run: ls -l suggested_changes - name: Suggest changes uses: parkerbxyz/suggest-changes@v1