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
83+ // Generate textlint cache path
84+ const textlintCachePath = join(process.env.RUNNER_TEMP, `.cache-textlint`);
85+ core.setOutput("textlint-cache-path", textlintCachePath);
86+
8087 // Generate textlint config file if not exists
8188 let textlintConfigPath = join(workingDirectory, ".textlintrc");
8289 if (!existsSync(textlintConfigPath)) {
@@ -96,6 +103,10 @@ runs:
96103 }
97104 core.setOutput("textlint-config-path", textlintConfigPath);
98105
106+ // Generate prettier cache path
107+ const prettierCachePath = join(process.env.RUNNER_TEMP, `.cache-prettier`);
108+ core.setOutput("prettier-cache-path", prettierCachePath);
109+
99110 // Generate markdownlint config file if not exists
100111 let markdownlintConfigPath = join(workingDirectory, ".markdownlint.json");
101112 if (!existsSync(markdownlintConfigPath)) {
@@ -130,52 +141,82 @@ runs:
130141 input : ${{ steps.prepare-variables.outputs.values-file }}
131142 working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
132143
133- - uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
134-
135- - id : npm-cache-dir
136- shell : bash
137- run : echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
138-
139- - uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
140- id : npm-cache
144+ - name : Setup Node.js
145+ uses : hoverkraft-tech/ci-github-nodejs/actions/setup-node@ce2bb8274a37c1219be2bcae2a1b2528c2c72957 # 0.19.0
141146 with :
142- path : ${{ steps.npm-cache-dir.outputs.dir }}
143- key : ${{ runner.os }}-node-${{ github.run_id }}
144- restore-keys : |
145- ${{ runner.os }}-node-
146-
147- - shell : bash
148- run : npm install -g prettier textlint @textlint/textlint-plugin-markdown textlint-filter-rule-comments textlint-rule-terminology
147+ working-directory : ${{ github.action_path }}
149148
150149 - name : Cache textlint
151150 id : cache-textlint
152151 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
153152 with :
154- path : ${{ runner.temp }}/. cache-textlint
153+ path : ${{ steps.prepare-variables.outputs.textlint- cache-path }}
155154 key : ${{ runner.os }}-textlint-${{ hashFiles(steps.prepare-variables.outputs.textlint-config-path) }}
156155
157- - name : Text lint and fix markdown files
158- shell : bash
159- working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
156+ - name : Text lint and fix files
157+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
160158 env :
161- 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 }}
162163 CONFIG_PATH : ${{ steps.prepare-variables.outputs.textlint-config-path }}
163- run : npx textlint --cache-location "$CACHE_PATH" --fix --config "$CONFIG_PATH" "$(pwd)/**/*.md"
164+ with :
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+ });
164175
165176 - name : Cache prettier
166177 id : cache-prettier
167178 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
168179 with :
169- path : ${{ runner.temp }}/. cache-prettier
180+ path : ${{ steps.prepare-variables.outputs.prettier- cache-path }}
170181 key : ${{ runner.os }}-prettier
171182
172183 - name : Prettify markdown and values file
173- shell : bash
174- working-directory : ${{ steps.prepare-variables.outputs.working-directory }}
184+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
175185 env :
176- 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 }}
177190 VALUES_FILE : ${{ steps.prepare-variables.outputs.values-file || '' }}
178- 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+ });
179220
180221 - name : Lint Fix markdown files
181222 uses : DavidAnson/markdownlint-cli2-action@30a0e04f1870d58f8d717450cc6134995f993c63 # v21.0.0
0 commit comments