Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js で Issue をリポジトリに還元する GitHub Actions を作る #55

Open
noraworld opened this issue Jun 30, 2023 · 9 comments

Comments

@noraworld
Copy link
Owner

No description provided.

@noraworld
Copy link
Owner Author

Error: Cannot find module '@actions/core' というエラーが発生した。

https://github.com/secondnoraworld/github-actions-issues-sample/actions/runs/5418535981/jobs/9850724432

どうやら Node.js で GitHub Actions を動作させるためには node_modules.gitignore に追加せずにコミットする必要があるらしい。

Azure/docker-login#3 (comment)

@noraworld
Copy link
Owner Author

  • Issues をクローズしたときに発火
  • Issues のタイトルを取得
  • そのタイトル名で特定の場所にファイルを作成 (場所はオプションで指定可能)
  • Issues の中のコメント一覧を取得
  • コメント同士を水平線 (---, <hr>) 区切りで分割しながら列挙
  • それをファイルに書き込む
  • コミットする

@noraworld
Copy link
Owner Author

すでに似たようなことをやっている人がいた。

https://ottan.jp/posts/2021/07/940598155/

けど具体的な仕組みが異なるのでこのプロジェクトは続行。

@noraworld
Copy link
Owner Author

別のワークフローを使って、Issue を自動で閉じたときにこっちのワークフローが発火しない問題が発生した。どうやらワークフローによって実行されたアクションをトリガーにして、また別のワークフローを発火させるというような再帰的な発火は GitHub 側で意図的に禁止されているようだ。

しかしワークアラウンドを見つけた。試してみたらうまくいった。

peter-evans/create-pull-request#48 (comment)

@noraworld
Copy link
Owner Author

ちなみに毎日自動で Issue を閉じたり開いたりするのは cron を使えば良いが、どうやらこのワークフローファイルを作ってからしばらくは実行されないようだ。最初はなぜ実行されなかったのか疑問だった。

https://gotohayato.com/content/514/

@noraworld
Copy link
Owner Author

GITHUB_TOKEN という環境変数は特になしもしなくてもスクリプトの中から呼び出せると思い込んでいたけどそんなことはなかった。ちゃんと YAML 内で定義する必要がある。

env:
  GITHUB_TOKEN: ${{ github.token }}

@noraworld
Copy link
Owner Author

GitHub Actions をマーケットプレイスに投稿しようとしたら名前で引っかかった。同名の GitHub Actions と被っていないことは確認したんだけど、どうやらそれ以外にもユーザ名や組織名とも被ってはいけないらしい。そして調べてみたところ、同名の組織 がすでに存在していた……。

別の名前を考えないといけないな。

@noraworld
Copy link
Owner Author

GitHub issue tracker というのもすでに GitHub Actions として存在する。

ちなみにこれはなんか JSON で保存する感じのものだったので今回のものとは競合しない。

@noraworld
Copy link
Owner Author

Issue Recorder という名前に変更してリリースした。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant