Open1

act チートシート

mii288mii288

Install

GHE と相性がいいので基本的に gh-act を使う
https://github.com/nektos/gh-act

以下コマンドは act -> gh act で実行する

gh extension install nektos/gh-act

Apple Silicon (M1/M2/M3)

act --container-architecture linux/amd64

~/.actrc に記載すると毎回不要
https://nektosact.com/usage/#configuration-file

--container-architecture linux/amd64
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest

基本

# ドライラン(実行確認のみ)
act -n

# ワークフロー指定
act -W .github/workflows/ci.yml

# job
## ジョブ一覧
act -l
## job 指定
act -j <job_id>

# イベント指定
act -e .event.json

環境変数

export GITHUB_TOKEN=$(gh auth token)
act

.secrets ファイル

# .secrets
GITHUB_TOKEN=ghp_xxxxx
WALLET_CONFIG_TOKEN=ghp_yyyyy

run:
act --secret-file .secrets

直指定

act --secret GITHUB_TOKEN=ghp_xxxxx

workflow_dispatch

.event.json を作成:

{
  "event_name": "workflow_dispatch",
  "inputs": { "env": "staging" }
}

run:

act -W .github/workflows/ci.yml -j build -e .event.json