6060 core.setOutput("working-directory", workingDirectory);
6161 core.setOutput("working-directory-name", basename(workingDirectory));
6262
63+ const filesPattern = join(workingDirectory, "**/*.md");;
64+ core.setOutput("files-pattern", filesPattern);
65+
6366 let valuesFile = ${{ toJson(inputs.values-file) }};
6467 if (valuesFile && valuesFile.length) {
6568 if(isAbsolute(valuesFile)) {
7780 core.setOutput("values-file", valuesFile);
7881 }
7982
80- // Generate markdownlint config file if not exists
81- let markdownlintConfigPath = join(workingDirectory, ".markdownlint.json");
82- if (!existsSync(markdownlintConfigPath)) {
83- markdownlintConfigPath = join(process.env.RUNNER_TEMP, `${Date.now()}.markdownlint.json`);
84-
85- const defaultConfig = {
86- "default": true,
87- "line-length": false
88- };
89- writeFileSync(markdownlintConfigPath, JSON.stringify(defaultConfig, null, 2));
90- }
91- core.setOutput("markdownlint-config-path", markdownlintConfigPath);
83+ // Generate textlint cache path
84+ const textlintCachePath = join(process.env.RUNNER_TEMP, `.cache-textlint`);
85+ core.setOutput("textlint-cache-path", textlintCachePath);
9286
9387 // Generate textlint config file if not exists
9488 let textlintConfigPath = join(workingDirectory, ".textlintrc");
@@ -109,6 +103,32 @@ runs:
109103 }
110104 core.setOutput("textlint-config-path", textlintConfigPath);
111105
106+ // Generate prettier cache path
107+ const prettierCachePath = join(process.env.RUNNER_TEMP, `.cache-prettier`);
108+ core.setOutput("prettier-cache-path", prettierCachePath);
109+
110+ // Generate markdownlint config file if not exists
111+ let markdownlintConfigPath = join(workingDirectory, ".markdownlint.json");
112+ if (!existsSync(markdownlintConfigPath)) {
113+ markdownlintConfigPath = join(process.env.RUNNER_TEMP, `${Date.now()}.markdownlint.json`);
114+
115+ const defaultConfig = {
116+ "default": true,
117+ "line-length": false,
118+ "outputFormatters": [
119+ [
120+ "markdownlint-cli2-formatter-template",
121+ {
122+ "template": "::${errorSeverity:${errorSeverity}}${errorSeverity!error} " +
123+ "file=${fileName},line=${lineNumber},${columnNumber:col=${columnNumber},}title=${ruleName}::${ruleDescription}"
124+ }
125+ ]
126+ ]
127+ };
128+ writeFileSync(markdownlintConfigPath, JSON.stringify(defaultConfig, null, 2));
129+ }
130+ core.setOutput("markdownlint-config-path", markdownlintConfigPath);
131+
112132 - uses : hoverkraft-tech/ci-github-common/actions/checkout@5e8d0e6d1e76d8577a070db6d0128a91b1c9d5ad # 0.30.2
113133
114134 - uses : losisin/helm-docs-github-action@a57fae5676e4c55a228ea654a1bcaec8dd3cf5b5 # v1.6.2
@@ -121,59 +141,82 @@ runs:
121141 input : ${{ steps.prepare-variables.outputs.values-file }}
122142 working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
123143
124- - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
125-
126- - id : npm-cache-dir
127- shell : bash
128- run : echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
129-
130- - uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
131- id : npm-cache
144+ - name : Setup Node.js
145+ uses : hoverkraft-tech/ci-github-nodejs/actions/setup-node@ce2bb8274a37c1219be2bcae2a1b2528c2c72957 # 0.19.0
132146 with :
133- path : ${{ steps.npm-cache-dir.outputs.dir }}
134- key : ${{ runner.os }}-node-${{ github.run_id }}
135- restore-keys : |
136- ${{ runner.os }}-node-
137-
138- - shell : bash
139- run : npm install -g prettier textlint @textlint/textlint-plugin-markdown textlint-filter-rule-comments textlint-rule-terminology
147+ working-directory : ${{ github.action_path }}
140148
141149 - name : Cache textlint
142150 id : cache-textlint
143151 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
144152 with :
145- path : ${{ runner.temp }}/. cache-textlint
153+ path : ${{ steps.prepare-variables.outputs.textlint- cache-path }}
146154 key : ${{ runner.os }}-textlint-${{ hashFiles(steps.prepare-variables.outputs.textlint-config-path) }}
147155
148- - name : Text lint and fix markdown files
149- shell : bash
150- working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
156+ - name : Text lint and fix files
157+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
151158 env :
152- CACHE_PATH : ${{ runner.temp }}/.cache-textlint
159+ NODE_PATH : ${{ github.action_path }}/node_modules
160+ WORKING_DIRECTORY : ${{ steps.prepare-variables.outputs.working-directory }}
161+ FILES_PATTERN : ${{ steps.prepare-variables.outputs.files-pattern }}
162+ CACHE_PATH : ${{ steps.prepare-variables.outputs.textlint-cache-path }}
153163 CONFIG_PATH : ${{ steps.prepare-variables.outputs.textlint-config-path }}
154- run : npx textlint --cache-location "$CACHE_PATH" --fix --config "$CONFIG_PATH" "$(pwd)/**/*.md"
155-
156- - name : Lint Fix markdown files
157- uses : DavidAnson/markdownlint-cli2-action@30a0e04f1870d58f8d717450cc6134995f993c63 # v21.0.0
158164 with :
159- fix : true
160- config : ${{ steps.prepare-variables.outputs.markdownlint-config-path }}
161- globs : ${{ steps.prepare-variables.outputs.working-directory }}/**/*.md
165+ script : |
166+ await exec.exec('npx', [
167+ 'textlint',
168+ '--cache-location', process.env.CACHE_PATH,
169+ '--fix',
170+ '--config', process.env.CONFIG_PATH,
171+ process.env.FILES_PATTERN,
172+ ], {
173+ cwd: process.env.WORKING_DIRECTORY,
174+ });
162175
163176 - name : Cache prettier
164177 id : cache-prettier
165178 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
166179 with :
167- path : ${{ runner.temp }}/. cache-prettier
180+ path : ${{ steps.prepare-variables.outputs.prettier- cache-path }}
168181 key : ${{ runner.os }}-prettier
169182
170183 - name : Prettify markdown and values file
171- shell : bash
172- working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
184+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
173185 env :
174- CACHE_PATH : ${{ runner.temp }}/.cache-prettier
186+ NODE_PATH : ${{ github.action_path }}/node_modules
187+ WORKING_DIRECTORY : ${{ steps.prepare-variables.outputs.working-directory }}
188+ CACHE_PATH : ${{ steps.prepare-variables.outputs.prettier-cache-path }}
189+ FILES_PATTERN : ${{ steps.prepare-variables.outputs.files-pattern }}
175190 VALUES_FILE : ${{ steps.prepare-variables.outputs.values-file || '' }}
176- run : npx prettier --cache-location "$CACHE_PATH" --write "$(pwd)/**/*.md" $VALUES_FILE
191+ with :
192+ script : |
193+ await exec.exec('npx', [
194+ 'prettier',
195+ '--cache-location', process.env.CACHE_PATH,
196+ '--write',
197+ process.env.FILES_PATTERN,
198+ process.env.VALUES_FILE,
199+ ], {
200+ cwd: process.env.WORKING_DIRECTORY,
201+ });
202+
203+ - name : Lint Fix markdown files
204+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
205+ env :
206+ NODE_PATH : ${{ github.action_path }}/node_modules
207+ WORKING_DIRECTORY : ${{ steps.prepare-variables.outputs.working-directory }}
208+ FILES_PATTERN : ${{ steps.prepare-variables.outputs.files-pattern }}
209+ CONFIG_PATH : ${{ steps.prepare-variables.outputs.markdownlint-config-path }}
210+ with :
211+ script : |
212+ await exec.exec('npx', [
213+ 'markdownlint-cli2',
214+ '--fix',
215+ '--config', process.env.CONFIG_PATH,
216+ process.env.FILES_PATTERN,
217+ ], {
218+ cwd: process.env.WORKING_DIRECTORY,
219+ });
177220
178221 - uses : actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
179222 if : inputs.github-app-id
0 commit comments