Keep your Github Action versions up-to-date. 使用の Github Actions を最新に!
Actually, Github's Dependabot can now handle this automatically. See these docs.
Table of Contents
If you use Github CI, you'll recognize fields like this in your Workflow Config:
- name: Check out my code
uses: actions/checkout@v2
But wait a minute, these Actions receive updates, so our configs can fall behind!
active
scans your projects and queries Github for the latest Action releases,
and updates your configs for you:
> active --local
Checking the following files:
--> .: go.yml
Updates available for .: go.yml:
actions/setup-go 2 --> 2.0.3
actions/checkout 2 --> 2.1.0
Would you like to apply them? [Y/n] Y
Updated.
Assuming you have a Golang environment set up:
go get github.com/fosskers/active
The simplest usage:
active --local
This will look for workflow files in ./.github/workflows/
.
active
is meant to be configured and ran on multiple projects at once.
Assuming you've configured it (see below), the default usage "just works":
> active
Checking the following files:
--> aura: ci.yaml
--> org-mode: ci.yaml
--> versions: ci.yaml
... etc ...
If you trust active
to do the right thing, you can use active -y
to
automatically accept all available updates.
With the --push
flag, active
will automatically make a commit on a new
branch, push it to Github, and open a PR:
> active --push
Checking the following files:
--> aura: ci.yaml
--> org-mode: ci.yaml
--> versions: ci.yaml
... work ...
Successfully opened a PR for versions! (#35)
Successfully opened a PR for org-mode! (#15)
Successfully opened a PR for aura! (#314)
This requires a valid Personal Access Token from Github (see below), and
will also create a new Git remote called active
for each project to ensure
that the token can be used properly for pushing.
A config file is not necessary to use active
, but having one will make your
life easier. By default, active
looks for its config file at
$HOME/.config/active.yaml
. Its contents should look like this:
projects:
- /home/you/code/some-project
- /home/you/code/another-project
- /home/you/code/third-project
git:
name: Your Name # (Optional) For --push
email: you@email.com # (Optional) For --push
user: you # (Optional) For --push
token: <oauth-token> # (Optional) For --push, and higher API rate limits in general.
name
and email
are used for commiting. user
is used for branch pushing,
and token
for opening the PR.
If you want to specify an alternate config location, use --config
.
If you have a Github account, then it's easy to generate a personal access token
for active
. First visit the Token
Settings on Github. Click Generate new
token, and give it public_repo
permissions:
Github CIの使用の方は下記の設定に見覚えはあるでしょう:
- name: Check out my code
uses: actions/checkout@v2
しかしActionsとは 見えない所でアップデートが現れ る物で、こういったアップデートを 見逃してしまう事があります。
active
はプロジェクトを分析し、使用のActionsを最新のバージョンに更新します:
> active --local
Checking the following files:
--> .: go.yml
Updates available for .: go.yml:
actions/setup-go 2 --> 2.0.3
actions/checkout 2 --> 2.1.0
Would you like to apply them? [Y/n] Y
Updated.
Golangの開発環境があれば:
go get github.com/fosskers/active
もっとも簡単な使い方としては:
active --local
./.github/workflows/
で見つかる「workflow」ファイルが分析されます。
本来active
はファイルで設定され、一括に履行するようにできています。
> active
Checking the following files:
--> aura: ci.yaml
--> org-mode: ci.yaml
--> versions: ci.yaml
... などなど ...
設定自体は下記を参考にしてください。
更にactive -y
("yes")で実行すれば、ユーザーの確認を得ずに全ての更新は自動的にさ
れます。
--push
を加えるとactive
は自動的にコミットを作り、ブランチをGithubに送り、新し
いPRが開かれます。
> active --push
Checking the following files:
--> aura: ci.yaml
--> org-mode: ci.yaml
--> versions: ci.yaml
... work ...
Successfully opened a PR for versions! (#35)
Successfully opened a PR for org-mode! (#15)
Successfully opened a PR for aura! (#314)
ただしこの場合はGithubからのPersonal Access Tokenが必要となります(下記を参考
に)。また、そのTokenが正確に使えるようにプッシュの前、active
という新しい「Git
remote」が各レポジトリで登録されます。
active
を使うには設定ファイルが特に必要ありませんが、あった方では後が色々と楽になります。
ファイル自体は$HOME/.config/active.yaml
に置きましょう。内容は以下の様に:
projects:
- /home/daisuke/code/some-project
- /home/daisuke/code/another-project
- /home/daisuke/code/third-project
# `--push`を使う時にのみ必須。
git:
name: Yamada Daisuke
email: yamadad@japan.jp
user: daisuke
token: <oauth-token>
--config
にて他の設定ファイルを指定できます。
Personal Access Tokenを作るのは簡単です。まずはGithubのToken
Settingsのページへ。Generate new token
をクリックし、public_repo
許可のみ与えたら完成です: