Gitlab CI에서 ruby ​​gems 업데이트 및 MR 자동 생성이 가능합니다.

dependabot/dependabot-core이라는 docker image를 사용하여 GitlabCI에서 ruby ​​gems를 업데이트하고 버전 업이 있던 것을 자동으로 MR 작성할 수 있습니다.

사전 준비


  • gitlab access token 만들기


  • .gitlab-ci.yml 조정



    ruby gems 업데이트를 위한 Job 추가


    dependabot/dependabot-core 컨테이너에 원하는 버전의 루비가 없을 수 있으므로 rbenv를 사용하여 설치하십시오.
    ※프로젝트의 부하에 ruby 의 버젼을 기재하고 있는 .ruby-version 가 있다고 합니다.


    작업 추가 후 .gitlab-ci.yml 파일

    .gitlab-ci.yml
    dependabot:
      image: dependabot/dependabot-core
      before_script:
        - git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
        - git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
        - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
        - echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
        - source ~/.bash_profile
        - rbenv install -v `cat ./.ruby-version` --skip-existing
        - rbenv global `cat ./.ruby-version`
        - gem install bundler
        - bundle install -j $(nproc) --path vendor
        - curl -O https://raw.githubusercontent.com/dependabot/dependabot-script/master/generic-update-script.rb
        - curl -O https://raw.githubusercontent.com/dependabot/dependabot-script/master/update-script.rb
      script:
        - bundle exec ruby ./generic-update-script.rb
      only:
        - schedules
    

    .gitlab-ci.yml에있는 dependabot 이외의 Job에 except : schedules 추가



    ruby gems의 갱신만이므로, rspec/lint등의 실행은 필요 없습니다

    .gitlab-ci.yml
    ...
    brakeman:
      stage: audit
      tags:
        - docker
        - gce
      except:
        - schedules
      script:
        - bundle exec brakeman -4 -A -w 1 -z
    ...
    

    Schedule에 Job 등록





    움직일 수 있는지 시도해보십시오.





    두 개의 젬 버조 업이 있었던 것 같습니다.





    MR 목록 확인



    확실히, 두 개의 MR이 올랐다.


    좋은 느낌이 완성되었습니다


    그리고는, 녹색의 merge 버튼을 클릭만.

    좋은 웹페이지 즐겨찾기