Coder Social home page Coder Social logo

nielsnijveldt / dependency-updates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rajbos/dependency-updates

0.0 1.0 0.0 222 KB

Docker containers to handle your dependency updates

Dockerfile 17.97% PowerShell 77.18% C# 4.47% Shell 0.38%

dependency-updates's Introduction

Dependency updates

This repository has been created to have a open source version of tools created to update your code dependencies in a reproducible way. Since the mainstream methods only work against the cloud versions of the repositories hosting parties and not against a private server, I needed an easy way to do this for multiple projects.

Supported ways to update

  • NuGet
  • Yarn
  • NPM

Supported targets to create a Pull Request

Examples

Example running it from GitHub Container Registry

docker run -it `
  -e gitUserName="Rob Bos" `
  -e gitUserEmail="[email protected]" `
  -e remoteUrl="https://my.gitlab.host/project/repository.git" `
  -e PAT=$env:GITLAB_PAT `
  -e gitLabProjectId="$env:gitLabProjectId" `
  ghcr.io/rajbos/local-dependency-updates:latest `
  pwsh start.ps1 -updateType "nuget" -targetType "gitlab"

Example running it from a GitLab pipeline:

My main usage for this image is to use it in a GitLab, as simple as possible. Below are the examples for NuGet and Yarn against a GitLab private server that we run on a schedule:

NuGet + GitLab

To update NuGet packages we use NuKeeper to check for updates.

nuget_update:on-schedule:
  only:
    - schedules
  image: 
    name: ghcr.io/rajbos/local-dependency-updates:test
  script:
  # we are in /builds/project/repository 
  - export PAT=$GitLabToken # load the GitLab access token storied in GitLab as environment variable 
  - export branchPrefix="nuget-updates" # prefix to use for the new branch
  # run call to update dependencies with settings what to do
  - pwsh .$CI_BUILDS_DIR/../dependency-updates/start.ps1 nuget gitlab

Yarn + GitLab

To update NPM packages with Yarn we use the default yarn upgrade command and check with git diff-index HEAD if there are any changed files.

Full set of yarn commands we trigger:

yarn
yarn eslint
yarn build
yarn upgrade

Job example:

yarn_update:on-schedule:
  stage: update-yarn
  only:
    - schedules
  image: 
    name: ghcr.io/rajbos/local-dependency-updates:latest
  script:   
    - export PAT=$GitLabToken # load the GitLab access token from GitLab in the env vars 
    - export branchPrefix="yarn-updates" # prefix to use for the new branch 
    # we need npm authentication for this project
    - echo "" >> .npmrc # add a new line first
    - curl -u${CREDENTIALS} $NPM_REGISTRY_AUTH >> .npmrc # add the credentials to login to e.g. a private Artefactory
    - echo "registry=$NPM_REGISTRY" >> .npmrc # add the private registry url
    # make sure the npmrc file is in the right location so yarn can use it
    - cp .npmrc $CI_BUILDS_DIR/../dependency-updates/
    - cd $CI_BUILDS_DIR/../dependency-updates
    - pwsh start.ps1 yarn gitlab

Additional parameters

The following startup parameters can be used:

Name Description Example
updateType Method to use for getting updates yarn, nuget, npm
targetType Target repository type gitlab
mergeRequestTitle Title to use for the merge request Defaults to 'Bumping NuGet/NPM packages'
mergeWhenPipelineSucceeds Bool in indicating if we set the flag 'merge when the pipeline succeeds' in GitLab 0 or 1
specificPackages Yarn only: only update the packages in the parameter 'package A', 'package B'

Building the container

docker build -t local-dependency-updates:latest .

Testing with a .NET 5.0 sample solution

After building the container you can run the local container against an example GitHub repository:

docker run -it -e gitUserName="rajbos" -e gitUserEmail="[email protected]" `
  -e remoteUrl="https://github.com/rajbos/dependency-updates" `
  local-dependency-updates:latest `
 pwsh start.ps1 -updateType "nuget"

dependency-updates's People

Contributors

rajbos avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.