diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5083af4e9..af257d64e 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -35,6 +35,10 @@ jobs: node-version: 22 cache: npm cache-dependency-path: '**/package.json' + - name: Is normal pull request + # check if is not a release pull request + id: pr + run: echo "is_normal=$(echo ${{ github.base_ref != 'master' && github.event_name == 'pull_request' }})" >> $GITHUB_OUTPUT - name: Detect changed files uses: dorny/paths-filter@v3 id: changes @@ -52,20 +56,14 @@ jobs: - 'sdk.d.ts' token: ${{ secrets.GITHUB_TOKEN }} - name: Don't edit slugs.md in pull requests - if: | - github.base_ref != 'master' && - github.event_name == 'pull_request' && - steps.changes.outputs.slugs == 'true' + if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.slugs == 'true' run: | echo -ne "Detected slugs.md file edition in PR.\n" 1>&2 echo -ne "Please revert it, we build the slugs.md" 1>&2 echo -ne " file automatically at releases.\n" 1>&2 exit 1 - name: Don't edit sdk.d.ts in pull requests - if: | - github.base_ref != 'master' && - github.event_name == 'pull_request' && - steps.changes.outputs.sdkts == 'true' + if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.sdkts == 'true' run: | echo -ne "Detected sdk.d.ts file edition in PR.\n" 1>&2 echo -ne "Please revert it, we build the sdk.d.ts" 1>&2 @@ -73,10 +71,22 @@ jobs: exit 1 - name: Install dependencies run: npm i --ignore-scripts --no-audit --no-fund + - name: Prepare icons + if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.icons == 'true' + run: sed -i 's/icons\/\*\.svg/$npm_config_icons/' package.json + - name: Prepare docs (docs changed) + # only lint changed docs + if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.docs == 'true' + run: sed -i "s/'\*\*\/\*\.md'/"'$npm_config_docs'"/" package.json + - name: Prepare docs (no docs changed) + # only lint README.md if no changes in docs + if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.docs != 'true' + run: sed -i "s/'\*\*\/\*\.md'/README.md/" package.json - name: Run linter run: | - sed -i 's/icons\/\*\.svg/$npm_config_icons/' package.json - npm run lint --icons='${{ steps.changes.outputs.icons_files }}' + npm run lint \ + --icons='${{ steps.changes.outputs.icons_files }}' \ + --docs='${{ steps.changes.outputs.docs_files }}' env: # Authorise GitHub API requests for editorconfig-checker GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmrc b/.npmrc index c57d3e28c..d519ad776 100644 --- a/.npmrc +++ b/.npmrc @@ -1,6 +1,3 @@ package-lock=false save-exact=true save-dev=true - -# Icons to lint with SVGLint on CI (see `lint` step on verify.yml workflow) -icons=icons/*.svg diff --git a/package.json b/package.json index b6e4eb80f..e3410b5af 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "jsonlint": "node scripts/lint/jsonlint.js", "svglint": "svglint --ci --config svglint.config.mjs icons/*.svg", "wslint": "editorconfig-checker", - "markdownlint": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"", + "markdownlint": "markdownlint-cli2 '**/*.md' '#node_modules'", "prepare": "husky", "prepublishOnly": "npm run build", "postpublish": "npm run clean",