Skip to content

Commit

Permalink
Make Update Dependencies Customizable (#32)
Browse files Browse the repository at this point in the history
* Allow updateDependencies to take in parameters that are set to default values

* Now takes in parameters that are set to a default value or pass in your own

* fix syntax errors

* Added documentation for the parameters
  • Loading branch information
jjonesdev authored Feb 25, 2020
1 parent 9713a7d commit 3a262b1
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,40 @@ lane :installProfiles do
end

desc "Updates project dependencies in Bundler and CocoaPods, then sends a pull request if there are changes"
lane :updateDependencies do
desc "#### Options"
desc " * **`branchname`**: Accepts an optional value to set the dependency updater branch. If no value is passed in, it will default to the ENV variable name."
desc " * **`base`**: Accepts an optional value to set the base branch for the created dependency update PR. If no value is passed in, it will default to master."
desc " * **`pullRequestTitle`**: Accepts an optional value to set the title for the created dependency update PR. If no value is passed in, it will default to Update Dependencies."
lane :updateDependencies do |options|
options[:branchname] ||= ENV["UPDATE_DEPENDENCIES_BRANCH"]
options[:base] ||= "master"
options[:pullRequestTitle] ||= "Update Dependencies"

fastlane_require 'fastlane-plugin-git_status'
xcversion(version: ENV["XCODE_VERSION"] || '~> 10.2')

xcversion(version: ENV["XCODE_VERSION"] || '~> 11.3')
bundle_update if File.exist?("../Gemfile.lock")
cocoapods_update if File.exist?("../Podfile.lock")
carthage(command: "update", no_build: true) if File.exist?("../Cartfile.resolved")
sendUpdatePullRequest unless git_status.empty?

sendUpdatePullRequest(
branchname: options[:branchname],
base: options[:base],
pullRequestTitle: options[:pullRequestTitle]
) unless git_status.empty?
end

desc "Sends a pull request with the current changes to dependencies"
lane :sendUpdatePullRequest do
fastlane_require 'fastlane-plugin-git_status'
lane :sendUpdatePullRequest do |options|
options[:branchname] ||= ENV["UPDATE_DEPENDENCIES_BRANCH"]
options[:base] ||= "master"
options[:pullRequestTitle] ||= "Update Dependencies"

branchname = ENV["UPDATE_DEPENDENCIES_BRANCH"]
fastlane_require 'fastlane-plugin-git_status'

branchname = options[:branchname]
base = options[:base]

create_git_branch(
branchname: branchname
)
Expand Down Expand Up @@ -251,8 +270,8 @@ lane :sendUpdatePullRequest do
api_token: ENV["GITHUB_TOKEN"],
repo: ENV["GITHUB_REPO"],
head: branchname,
base: "master",
title: "Update Dependencies"
base: base,
title: options[:pullRequestTitle]
)
end

Expand Down

0 comments on commit 3a262b1

Please sign in to comment.