経緯
試験勉強を始めるとついつい部屋の掃除をしちゃいますよね?
(訳:RubyKaigiの資料の現実逃避で全く関係ないgemを作った)
どんなgem ?
名前からピンときた人もいるかもしれませんが、CircleCIで bundle update のPRを作る circleci-bundle-update-pr のGitLab版です。

使い方
0. 事前準備
READMEを参考に GITLAB_API_ENDPOINT と GITLAB_API_PRIVATE_TOKEN と OCTOKIT_ACCESS_TOKEN をEnvironment variablesに設定します

1-A. .gitlab-ci.ymlに直接書く
.gitlab-ci.yml に下記のようなものを書きます
stages: - build continuous_bundle_update: stage: build image: ruby cache: key: "$CI_BUILD_NAME" paths: - vendor/bundle/ before_script: # Set timezone to Asia/Tokyo - cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime script: - bundle install --path vendor/bundle - bundle clean - gem install --no-doc gitlabci-bundle-update-mr - gitlabci-bundle-update-mr --user="GitLab CI" --email="gitlabci@example.com" --labels="bundle update" only: - schedules
1-B
GitLab v11.4でinclude *1がCoreに入ったので、せっかくの機会なのでincludeに対応しました。
その場合は下記のような書き方です。
include: - remote: "https://gitlab.com/sue445/gitlabci-bundle-update-mr/blob/master/gitlabci-templates/continuous_bundle_update.yml" continuous_bundle_update: stage: build variables: # override variables (followings are defailts) CACHE_VERSION: "v1" GIT_EMAIL: "gitlabci@example.com" GIT_USER: "GitLab CI" LABELS: "bundle update" OPTIONS: "" before_script: # Set timezone to Asia/Tokyo - cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
さっきと違って変数の上書きを除けばちょっと短くなるのがポイントです。
2. スケジューラに登録する
GitLab CIでscheduler(cronのように定期実行する機能)を使うにはymlではなくリポジトリの設定から登録する必要があります

今回のgemを作るにあたって
アップデートされたgemのcompareリンクを生成する部分は前述のcircleci-bundle-update-pr同様 compare_linker を使っているので、circleci-bundle-update-prと同じ内容のMRが作れます。
gitlabci-bundle-update-mrで作ったMR

circleci-bundle-update-prで作ったPR

ただしgitlabci-bundle-update-mrから使おうとすると一部使いづらい部分があったので、汎用的に使えるように一部ロジックをpublicメソッドに切り出すPRを投げました。
*1:CircleCIのorbのように外部のymlを取り込めるようにする機能