From 463bc536511418e7ccc92b67d91e21bd171aaead Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Fri, 6 Sep 2024 15:23:25 +0200 Subject: [PATCH] Create vale.yml Copied from https://github.com/rancher/rancher-docs/blob/main/.github/workflows/vale.yml --- .github/workflows/vale.yml | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/vale.yml diff --git a/.github/workflows/vale.yml b/.github/workflows/vale.yml new file mode 100644 index 000000000..1ae483220 --- /dev/null +++ b/.github/workflows/vale.yml @@ -0,0 +1,62 @@ +# This action gets all changed markdown files in /docs and /versioned_docs using tj-actions/changed-files@v42 +# It compares new commits in the PR with the base commit (github.event.pull_request.base.sha) +# It checks if no markdown files are changed +# It shows a count of markdown files and lists all changed markdown files +# It uses Vale (https://vale.sh/docs/vale-cli/installation/) to provide feedback base off the SUSE Style Guide / OpenSUSE style rules (https://github.com/openSUSE/suse-vale-styleguide) +# Copied from https://github.com/rancher/rancher-docs/blob/main/.github/workflows/vale.yml + +name: Style check +on: + pull_request: + paths-ignore: + - '**/README.md' + +jobs: + vale-lint: + name: runner / vale + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + continue-on-error: true + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + submodules: true + - name: Get all changed markdown files + continue-on-error: true + id: changed-markdown-files + uses: tj-actions/changed-files@v42 + with: + # Avoid using single or double quotes for multiline patterns + files: | + docs/** + versioned_docs/** + separator: "," + base_sha: ${{ github.event.pull_request.base.sha }} + env: + ALL_CHANGED_FILES: ${{ 0 }} + - name: No files changed? + continue-on-error: true + if: steps.changed-markdown-files.outputs.any_changed == 'false' + run: | + echo "No files changed" + echo "ALL_CHANGED_FILES=$ALL_CHANGED_FILES" >> $GITHUB_ENV + - name: List all changed files markdown files + continue-on-error: true + if: steps.changed-markdown-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }} + ALL_CHANGED_FILES_COUNT: ${{ steps.changed-markdown-files.outputs.all_changed_files_count }} + SHA: ${{ github.head_ref }} + HEAD: ${{ github.base_ref }} + run: | + echo "Total Files Changed:" ${ALL_CHANGED_FILES_COUNT} + echo ${ALL_CHANGED_FILES} + echo "ALL_CHANGED_FILES=$ALL_CHANGED_FILES" >> $GITHUB_ENV + - uses: errata-ai/vale-action@v2.1.0 + continue-on-error: true + if: steps.changed-markdown-files.outputs.any_changed == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + separator: ", " + files: ${{ env.ALL_CHANGED_FILES }}