LoginSignup
1
0

More than 1 year has passed since last update.

github actionsをローカルで実行 act

Posted at

使うメリット

ローカルで実行できるのでトライ&エラーしやすい

インストール方法

brew install act

※dockerもインストールされていること
GitHub CLI 拡張としてのインストールもできるらしい

ワークフローの一覧表示

act -l

イベント指定

pull_requestイベントをトリガーとしたい場合は以下のように引数を与える。

$ act pull_request

使い方具体例

ワークフローを直接指定

act -W .github/workflows/helloworld.yaml pull_request

特定のジョブのみ実行

-j

act -j cherry-pick -s secrets=PAT

シークレットを渡す

-s

act -s MY_SECRET=somevalue
act -s secrets=PAT

ジョブ実行後コンテナを消したくない時

-rでreuseできる=コンテナが消えない

act -r -j cherry-pick

ドライラン

-n

イベントも練り込むことができる

「-e」または「--eventpath」

act -W .github/workflows/helloworld.yaml pull_request -e pull_request.json
たとえば、、、下記のようなことがyamlに書いてあったら上のコマンドでjson用意しておけば、架空のイベントも練り込める

if:github.event.pull_request.merged == true
pull_request.json
{
  "pull_request": {
    "merged": true
  }

手動でパラメータを渡すこともできる

act --input NAME=somevalue-入力somevalueの値として使用しますNAME。
act --input-file my.input-my.inputファイルから入力値を読み込みます。

参考資料

https://zenn.dev/yumemi_inc/articles/203779a4eba922
公式ドキュメント
https://github.com/nektos/act

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0