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のActionを作る
Search
meil
September 20, 2019
Programming
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GitHub ActionsのActionを作る
meil
September 20, 2019
More Decks by meil
See All by meil
クラシルの開発で使ってるGitHub Actions
meilcli
0
210
プログラミング言語(?)を自作した話
meilcli
0
890
GitHub Actions入門
meilcli
0
460
Azure Pipelinesのすゝめ
meilcli
0
340
Other Decks in Programming
See All in Programming
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
240
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.6k
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
890
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
130
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
460
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
200
Claude Team Plan導入・ガイド
tk3fftk
0
240
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
410
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
130
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.2k
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
130
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
150
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
How to train your dragon (web standard)
notwaldorf
97
6.7k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
A better future with KSS
kneath
240
18k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
360
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Done Done
chrislema
186
16k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
Transcript
GitHub ActionsのActionを作る Mobile Act OSAKA #11
自己紹介 • Twitter: @penguin_sharp • GitHub: MeilCli • Blog: https://blog.meilcli.net/
• Skill: C#, Kotlin, Android, Azure Pipelines • Work: Fenrir Inc. ◦ Android Application Engineer ◦ 発言は個人の見解であり所属する組織の公式見解ではありません
GitHub Actions軽くまとめ • ベータ版 ◦ https://twitter.com/natfriedman/status/1174158823877042177 • Azure Pipelinesのクローン •
Windows, Linux, macOSで動作 • 1つの構成単位としてworkflow、1つの実行ステップ単位としてactionがある
Actionを作るには • 作り方は2種類 ◦ Docker container ◦ JavaScript(Node.js) ← 今回試すのはこっち
• Docker containerはLinuxでのみ対応
注意: 今回作るものはあくまで学習目 的です そして、Dangerのactionを作り ます
そもそもDangerとは • コードレビューを自動化するためのツールみたいなもの ◦ https://github.com/danger/danger • 今回はRuby版を使用
Actionを作る • Node.jsをインストール • Visual Studio Codeを用意 • リポジトリーの作成 ◦
npm init -y ◦ npm install -g typescript ◦ tsc -init ◦ npm install @actions/core --save ◦ npm install @actions/io --save ◦ npm install @actions/exec --save ◦ etc..
Actionを作る まずはactionの実行コードを書いていく import * as core from '@actions/core'; async function
run() { try { } catch (error) { core.setFailed(error.message); } } run();
Actionを作る action外でDangerを動かすための環境がセット アップされている前提にする import * as io from '@actions/io'; async
function checkEnvironment() { await io.which("ruby", true); await io.which("bundle", true); }
Actionを作る actionに渡された引数を取得する interface Option { readonly dangerVersion: string; readonly pluginsFile:
string | null; readonly dangerFile: string; readonly dangerId: string; } async function getOption(): Promise<Option> { return { dangerVersion: core.getInput( "danger_version" , { required: true }), pluginsFile: core.getInput( "plugins_file" ), dangerFile: core.getInput( "danger_file" , { required: true }), dangerId: core.getInput( "danger_id" , { required: true }) } }
Actionを作る Dangerをインストール import * as exec from '@actions/exec' ; async
function installDanger(option: Option) { await exec.exec( `gem install danger --version "${option.dangerVersion }"`, undefined , { failOnStdErr: true } ); if (option.pluginsFile != null) { await exec.exec( `bundle install --gemfile= ${option.pluginsFile }`, undefined , { failOnStdErr: true } ); } }
Actionを作る Danger実行 async function runDanger(option: Option) { await exec.exec( `danger
--dangerfile=${option.dangerFile} --danger_id=${option.dangerId}`, undefined, { failOnStdErr: true } ); }
Actionを作る action.ymlを書く name: 'Danger action' description : 'run danger' author:
'MeilCli' inputs: danger_version : description : 'danger version' default: '~> 6.0' plugins_file : description : 'gemfile for danger plugin' danger_file : description : 'dangerfile for danger' required : true danger_id : description : 'danger id, set identifier string' required : true runs: using: 'node12' main: 'lib/main.js'
Actionを使う workflowのymlを書く • action.ymlのinputsに対してwithで値を渡す • usesにアカウント名/レポジトリ名を指定 ◦ @のあとはバージョン情報 ◦ ここではTagを指定
jobs: danger: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-ruby@v1 with: ruby-version: '2.6' - uses: MeilCli/danger-action@v1 with: plugins_file: 'Gemfile' danger_file: 'Dangerfile' danger_id: 'danger-pr' env: DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Actionを使う WorkflowやDangerfileなどをセットアップしておく と、PullRequestでこのようなコメントが送られてくる ようになる
Actionを公開する • 基本的にリポジトリーを公開しておくだけでOK ◦ 注意点として.jsファイルとそれが参照する node_modulesも公開しておく必要がある • Marketplaceにも公開できる ◦ https://github.com/marketplace?type=actions
◦ Marketplaceに公開する場合はaction.ymlに必要な情報を記述しておく必要あり ▪ 名前、説明、アイコンなど
おわりに • まとめ ◦ GitHub ActionのactionはTypeScriptで簡単に作ることができる ◦ だからみんなもどんどん作っていってくれ~~ • 今回作ったもの
◦ https://github.com/MeilCli/danger-action ◦ https://github.com/marketplace/actions/danger-action • 解説 ◦ https://blog.meilcli.net/2019/09/15/155447