reviewdog #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## @(#) : reviewdog / lint new articles | |
# | |
# @version 1.0.0 | |
# @author Furukawa Atsushi <atsushifx@gmail.com> | |
# @since 2025-02-05 | |
# @license MIT | |
# | |
# @desc<< | |
# | |
# lint new articles on GitHub | |
# | |
#<< | |
name: reviewdog | |
# PR及び手動でAction実行 | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- '**/*.md' | |
workflow_dispatch: | |
# 実行するAction | |
jobs: | |
lint-on-github: | |
name: lint on github | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: fetch main repository | |
run: | | |
git fetch origin main | |
- name: get changed files | |
id: changed | |
run: | | |
head_sha="$(git rev-parse HEAD)" | |
base_sha="$(git rev-parse origin/main)" | |
echo "head: ${head_sha}" | |
echo "base: ${base_sha}" | |
files=$(git diff --name-only ${base_sha} ${head_sha} -- '**/*.md') | |
echo "changed: ${files}" | |
echo "files=${files}" >> $GITHUB_OUTPUT | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 10 | |
- name: restore cache | |
id: cache-restore | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-cache | |
path: | | |
node_modules | |
~/.pnpm-store | |
.textlintcache | |
- name: nstall script executable | |
run: | | |
chmod +x ./bin/installlinter.sh | |
- name: Install linters | |
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }} | |
run: | | |
./bin/installlinter.sh "--save-prod --reporter silent " | |
pnpm list | |
- name: lint text | |
if: ${{ steps.changed.outputs.files != '' }} | |
env: | |
changed_files: "${{ steps.changed.outputs.files }}" | |
run: | | |
pnpm exec textlint --cache -- ${changed_files}" | |
- name: lint markdown | |
if: ${{ steps.changed.outputs.files != '' }} | |
env: | |
changed_files: "${{ steps.changed.outputs.files }}" | |
run: | | |
pnpm exec markdownlint-cli2 -- ${changed_files} | |
- name: Always save cache | |
id: cache-save | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.cache-restore.outputs.cache-primary-key }} | |
path: | | |
node_modules | |
~/.pnpm-store | |
.textlintcache |