1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FoundingBaseAdvent Calendar 2024

Day 16

Dependabot で gitsubmodule の更新を検知し Pull request を作成してもらう

Last updated at Posted at 2024-12-15

はじめに

GitHub で利用できる Dependabot 。 Git Submodule の更新を行えることはご存知でしょうか?
捨てメールアドレスかを判定する npm package を管理していますが 参照元のレポジトリが更新されたかを Dependabot を使って検知しているのでその設定方法を簡単に記載します。

dependabot.yml に設定を追加する

dependabot.yml に gitsubmodule の更新を有無を確認する設定を追加します。
package-ecosystem'gitsubmodule' と記載するだけで設定は完了します。

.github/dependabot.yml
version: 2
updates:
  - package-ecosystem: 'gitsubmodule'
    directory: '/'

設定を記載したら default branch (main/master) に push すれば設定完了です。
必要に応じて実行間隔や assign の設定を追加してください。

動作確認

設定が有効になると、下記のようなログとともに、必要であれば Pull request が作成されます。

Run github/dependabot-action@main
  env:
    DEPENDABOT_DISABLE_CLEANUP: 1
    DEPENDABOT_ENABLE_CONNECTIVITY_CHECK: 0
    GITHUB_TOKEN: ***
    GITHUB_DEPENDABOT_JOB_TOKEN: ***
    GITHUB_DEPENDABOT_CRED_TOKEN: ***
🤖 ~ starting update ~
Fetching job details
Pulling updater images
Starting update process
Created proxy container: 47a5aae13c5d00d126eeb4078ed9c0ea9bdad1c6f29cf567c0c541489c288d7d
Created container: f86faecd92dcee3488b12c2911198d9b53554f973906379f9136f694c3d9c656
  proxy | 2024/12/05 10:59:01 proxy starting, commit: 8e9ec47aa774551212c265bf0c9da8efe34eac8e
  proxy | 2024/12/05 10:59:01 Listening (:1080)
updater | Updating certificates in /etc/ssl/certs...
updater | rehash: warning: skipping ca-certificates.crt,it does not contain exactly one certificate or CRL
updater | 1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
updater | done.
updater | 2024/12/05 10:59:05 INFO <job_927996889> Starting job processing
2024/12/05 10:59:05 INFO <job_927996889> Job definition: {"job":{"allowed-updates":[{"dependency-type":"direct","update-type":"all"}],"commit-message-options":{"prefix":null,"prefix-development":null,"include-scope":null},"credentials-metadata":[{"type":"git_source","host":"github.com"}],"debug":null,"dependencies":null,"dependency-groups":[],"dependency-group-to-refresh":null,"existing-pull-requests":[[{"dependency-name":"disposable-email-domains","dependency-version":"80385d0d85af16049c0fbe958d0b6b3c989cb61a","directory":"/"}],[{"dependency-name":"disposable-email-domains","dependency-version":"aa8171d4d765201102293490b8efb5fb378a612d","directory":"/"}],[{"dependency-name":"disposable-email-domains","dependency-version":"0c27e671231d27cf66370034d7f6818037416989","directory":"/"}],[{"dependency-name":"disposable-email-domains","dependency-version":"910d8b3a0a8690d6c436d859e77c1557fb64ea9a","directory":"/"}]],"existing-group-pull-requests":[],"experiments":{"record-ecosystem-versions":true,"record-update-job-unknown-error":true,"proxy-cached":true,"move-job-token":true,"dependency-change-validation":true,"nuget-native-analysis":true,"nuget-use-direct-discovery":true,"enable-file-parser-python-local":true,"lead-security-dependency":true,"enable-record-ecosystem-meta":true,"enable-corepack-for-npm-and-yarn":true},"ignore-conditions":[],"lockfile-only":false,"max-updater-run-time":2700,"package-manager":"submodules","proxy-log-response-body-on-auth-failure":true,"requirements-update-strategy":null,"reject-external-code":false,"security-advisories":[],"security-updates-only":false,"source":{"provider":"github","repo":"mziyut/disposable-email-domains-js","branch":null,"directory":"/.","api-endpoint":"https://api.github.com/","hostname":"github.com"},"updating-a-pull-request":false,"update-subdependencies":false,"vendor-dependencies":false,"repo-private":false}}
  proxy | 2024/12/05 10:59:05 [002] GET https://github.com:443/mziyut/disposable-email-domains-js/info/refs?service=git-upload-pack
  proxy | 2024/12/05 10:59:05 [002] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:05 [002] 200 https://github.com:443/mziyut/disposable-email-domains-js/info/refs?service=git-upload-pack
  proxy | 2024/12/05 10:59:05 [004] POST https://github.com:443/mziyut/disposable-email-domains-js/git-upload-pack
2024/12/05 10:59:05 [004] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:05 [004] 200 https://github.com:443/mziyut/disposable-email-domains-js/git-upload-pack
  proxy | 2024/12/05 10:59:05 [006] POST https://github.com:443/mziyut/disposable-email-domains-js/git-upload-pack
2024/12/05 10:59:05 [006] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:05 [006] 200 https://github.com:443/mziyut/disposable-email-domains-js/git-upload-pack
  proxy | 2024/12/05 10:59:05 [008] GET https://github.com:443/martenson/disposable-email-domains.git/info/refs?service=git-upload-pack
2024/12/05 10:59:05 [008] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:05 [008] 200 https://github.com:443/martenson/disposable-email-domains.git/info/refs?service=git-upload-pack
  proxy | 2024/12/05 10:59:05 [010] POST https://github.com:443/martenson/disposable-email-domains.git/git-upload-pack
2024/12/05 10:59:05 [010] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:05 [010] 200 https://github.com:443/martenson/disposable-email-domains.git/git-upload-pack
  proxy | 2024/12/05 10:59:05 [012] POST https://github.com:443/martenson/disposable-email-domains.git/git-upload-pack
2024/12/05 10:59:05 [012] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:06 [012] 200 https://github.com:443/martenson/disposable-email-domains.git/git-upload-pack
  proxy | 2024/12/05 10:59:06 [014] GET https://github.com:443/martenson/disposable-email-domains.git/info/refs?service=git-upload-pack
2024/12/05 10:59:06 [014] 200 https://github.com:443/martenson/disposable-email-domains.git/info/refs?service=git-upload-pack
  proxy | 2024/12/05 10:59:06 [016] POST https://github.com:443/martenson/disposable-email-domains.git/git-upload-pack
2024/12/05 10:59:06 [016] * authenticating git server request (host: github.com)
  proxy | 2024/12/05 10:59:11 [046] 200 https://api.github.com:443/repositories/23594485/contents/
  proxy | 2024/12/05 10:59:11 [048] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
2024/12/05 10:59:11 [048] * authenticating github api request with token for api.github.com
  proxy | 2024/12/05 10:59:11 [048] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:11 [050] GET https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
2024/12/05 10:59:11 [050] * authenticating github api request with token for api.github.com
  proxy | 2024/12/05 10:59:11 [050] 200 https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:11 [052] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:11 [052] * authenticating github api request with token for api.github.com
  proxy | 2024/12/05 10:59:11 [052] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:11 [054] GET https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:11 [054] * authenticating github api request with token for api.github.com
  proxy | 2024/12/05 10:59:11 [054] 200 https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:12 [056] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
2024/12/05 10:59:12 [056] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [058] GET https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [058] 200 https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [060] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:12 [060] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:12 [062] GET https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:12 [062] 200 https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:12 [064] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
2024/12/05 10:59:12 [064] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [066] GET https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [066] 200 https://api.github.com:443/repositories/23594485/commits?sha=4daba71d96d6ded3eba33d9cd926395f576df92f
  proxy | 2024/12/05 10:59:12 [068] GET https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:12 [068] 301 https://api.github.com:443/repos/martenson/disposable-email-domains/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:12 [070] GET https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
2024/12/05 10:59:12 [070] 200 https://api.github.com:443/repositories/23594485/commits?sha=8b012893c5575f6bf1aace5d56715abf149706ba
  proxy | 2024/12/05 10:59:12 [072] POST /update_jobs/927996889/create_pull_request
  proxy | 2024/12/05 10:59:12 [072] 204 /update_jobs/927996889/create_pull_request
  proxy | 2024/12/05 10:59:12 [074] POST /update_jobs/927996889/record_ecosystem_meta
  proxy | 2024/12/05 10:59:12 [074] 204 /update_jobs/927996889/record_ecosystem_meta
  proxy | 2024/12/05 10:59:12 [076] PATCH /update_jobs/927996889/mark_as_processed
  proxy | 2024/12/05 10:59:12 [076] 204 /update_jobs/927996889/mark_as_processed
updater | 2024/12/05 10:59:12 INFO <job_927996889> Finished job processing
updater | 2024/12/05 10:59:12 INFO Results:
+--------------------------------------------------------------------+
|                Changes to Dependabot Pull Requests                 |
+---------+----------------------------------------------------------+
| created | disposable-email-domains ( from `4daba71` to `8b01289` ) |
+---------+----------------------------------------------------------+
Cleaned up container f86faecd92dcee3488b12c2911198d9b53554f973906379f9136f694c3d9c656
  proxy | 2024/12/05 10:59:12 Posting metrics to remote API endpoint
2024/12/05 10:59:12 10/37 calls cached (27%)
🤖 ~ finished ~

最後に

Git Submodule を使う場面は少なくなってきていますが、Dependabot を使うことで工数をかけずに最新の差分を追従できるので、 Submodule を使っている方がいればぜひ設定してみてください。

Ref

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?