Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GitHub ActionsでZennブログの校正を自動化してみた
Search
YouYou
April 04, 2021
Technology
3.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GitHub ActionsでZennブログの校正を自動化してみた
詳細ブログ⇓
https://zenn.dev/yuta28/articles/blog-lint-ci-reviewdog
YouYou
April 04, 2021
More Decks by YouYou
See All by YouYou
AWSマネコンに複数のアカウントで入れるようになりました
yuhta28
2
300
今インフラ技術をイチから学び直すなら
yuhta28
1
310
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
3
680
Datadog外形監視基盤をEC2から ECSへ移行してみた
yuhta28
0
1.8k
アウトプット頑張ったら企業からLT登壇の依頼がきた話
yuhta28
1
1.9k
小さなことから始めるAWSコスト最適入門
yuhta28
1
1.4k
Datadogのコストも監視しよう
yuhta28
1
1.1k
Rcloneを使った定期的なストレージ同期
yuhta28
0
850
Pulumiを触ってみよう
yuhta28
1
2.7k
Other Decks in Technology
See All in Technology
ボーイスカウトルールでメモリやスキルを改善しよう
azukiazusa1
4
1.5k
GoでCコンパイラを作った話
repunit
0
140
Webアプリ認証の全体像 / The Big Picture of Web App Authentication
kitano_yuichi
1
350
探索・可視化・自動化を一本化 Amazon Quickでデータ活用スピードを上げる方法
koheiyoshikawa
0
140
“それは自分の仕事じゃない"を越えて行け
yuukiyo
1
500
壊して学ぶAWS CDK: そのcdk deployで消えるもの、残るもの
k_adachi_01
1
440
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
300
AI時代のYAGNI:「爆速で無駄になった機能」からの学び / 20260720 Naoki Takahashi
shift_evolve
PRO
3
450
SoccerMaster: A Vision Foundation Model for Soccer Understanding
kzykmyzw
0
150
AI、CDK と協働する Full TypeScript アプリケーション開発 / Full TypeScript Application with AI and CDK
geekplus_tech
2
430
ゴールデンパスは敷いただけでは道にならない ─ 企画部門のエンジニアが技術標準を事業価値に変えるまで
mhrtech
1
240
インシデント事例と パッケージの全量解析に学ぶ ソフトウェアサプライチェーンの守り方 / supply-chain-attack-defense
flatt_security
0
560
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
40k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
350
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.6k
Side Projects
sachag
455
43k
Building the Perfect Custom Keyboard
takai
2
820
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
190
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
BBQ
matthewcrist
89
10k
4 Signs Your Business is Dying
shpigford
187
22k
Automating Front-end Workflow
addyosmani
1370
210k
Evolving SEO for Evolving Search Engines
ryanjones
0
240
Transcript
GitHub Actionsで ブログの校正を自動化してみた
Name:ユータ Occupation:インフラエンジニア Twitter:@Y0u281 (オーでなくゼロです) ブログ:https://zenn.dev/yuta28 → 普段触るもの:AWS Ansible Linux Mint
自己紹介 Twitter
目次 • 背景 • 技術スタック紹介 ◦ textlint ◦ reviewdog •
実装 • 工夫ポイント • まとめ
背景 • ZennブログをGitHub連携することができるようになった☆ ◦ Zenn個人開発の限界に挑んだ話 - devsumi 2021 詳しくは開発者のプレゼン 👀 •
CIツールを導入する事で自動化が可能に👏 ◦ リポジトリを更新する度にドキュメントの校正 ◦ イイ感じのブログ執筆
textlint • mdファイルやプレーンテキスト向けのLinterツール • npm install textlint `textlint-rurle` → ルールもインストール •
デフォルトルールが存在せず、自分でルールを決めなければならない • .textlintrc にルールを記述 https://textlint.github.io/
textlint # .textlintrc { "rules": { "preset-smarthr": { "sentence-length": false
}, "prh": { "rulePaths": [ "dict/smarthr-prh-basic.yml", "dict/smarthr-prh-tech-word.yml" ] } } } ルール • textlint-rule-preset-smarthr • textlint-rule-prh 参照 よりよい文書を書くための校正ツール「 textlint」の SmartHR用ルールプリセットを公開しました! |SmartHRオープン社内報
reviewdog • GitHubにlinterツールで検知した指摘事項をレビューコメントに投稿 • Goで書かれたOSS • Circle CIやGitHub Actionsなど複数のCIサービスと連携可能 https://github.com/reviewdog/reviewdog
実装 jobs: reviewdog-github-check: name: reviewdog (github-check) runs-on: ubuntu-latest steps: #reviewdogのアクション
- uses: reviewdog/action-setup@v1 with: reviewdog_version: latest #textlintを動かすための nodeアクション - uses: actions/setup-node@v2 - name: Install textlint run: 'npm install --save-dev textlint-rule-preset-smarthr textlint-rule-prh' - name: Install dependent module run: npm install - name: Execute textlint for ブログ記事 run: | npx textlint -f checkstyle "articles/*.md" >> .textlint.log - name: Run reviewdog # textlintで文章上のミスがあった場合のみ、 reviewdogを実行させるようにする if: failure() env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cat .textlint.log | reviewdog -f=checkstyle -name="textlint" -reporter="github-pr-review" 1) reviewdog,nodeのアクションを起動 2) textlintのインストール 3) textlintを記事に対して実行 4) 何かしらの記載ミスが有った場合のみtextlintの出力結果を reviewdogに渡してGitHubにレビューコメントを投稿
デモ イメージ図
工夫ポイント • キャッシュを使って高速化 ◦ GitHub Actionの公式にactions/cache • stepが失敗するとキャッシュしてくれない • stepが終了してもキャッシュしてくれるアク
ションを使う https://github.com/pat-s/always-upload-c ache #stepsが失敗(文章の乱れ)した場合でもcacheを取得するようにする uses: pat-s/
[email protected]
env: cache-name: cache-node-modules with: path: ~/.npm key: node-${{ hashFiles('**/package-lock.json') }} restore-keys: | node-
工夫ポイント • キャッシュ前(初回実行) 50秒 • キャッシュ取得後(2回目以降) 29秒
まとめ
ありがとうございました より詳しい内容は以下のブログで ↓ GitHub ActionsでZennブログの校 正を自動化してみた