Skip to content

Commit 79d3719

Browse files
committed
Fix BUILDKITE_PULL_REQUEST being false not nil
1 parent dd3021c commit 79d3719

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fastlane/Fastfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ platform :ios do
651651
UI.important('Remember not to commit the modified project file! The change is only meant to allow building for Enterprise where App Clips are not supported.')
652652

653653
build_number = ENV.fetch('BUILDKITE_BUILD_NUMBER', '0')
654-
pr_or_branch = ENV.fetch('BUILDKITE_PULL_REQUEST', nil)&.then { |num| "PR ##{num}" } || ENV.fetch('BUILDKITE_BRANCH', nil)
654+
pr_or_branch = pull_request_number&.then { |num| "PR ##{num}" } || ENV.fetch('BUILDKITE_BRANCH', nil)
655655

656656
build_app(
657657
scheme: SCHEME_ENTERPRISE,
@@ -678,7 +678,7 @@ platform :ios do
678678
require_env_vars!('FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY')
679679

680680
release_notes = <<~NOTES
681-
Pull Request: ##{ENV.fetch('BUILDKITE_PULL_REQUEST', 'N/A')}
681+
Pull Request: ##{pull_request_number || 'N/A'}
682682
Branch: `#{ENV.fetch('BUILDKITE_BRANCH', 'N/A')}`
683683
Commit: #{ENV.fetch('BUILDKITE_COMMIT', 'N/A')[0...7]}
684684
NOTES
@@ -691,7 +691,7 @@ platform :ios do
691691
groups: FIREBASE_TESTERS_GROUP
692692
)
693693

694-
next if ENV.fetch('BUILDKITE_PULL_REQUEST', 'false') == 'false'
694+
next if pull_request_number.nil?
695695

696696
# Post PR Comment
697697
comment_body = prototype_build_details_comment(
@@ -700,7 +700,7 @@ platform :ios do
700700
)
701701
comment_on_pr(
702702
project: GITHUB_REPO,
703-
pr_number: Integer(ENV.fetch('BUILDKITE_PULL_REQUEST', nil)),
703+
pr_number: pull_request_number,
704704
reuse_identifier: 'prototype-build-link',
705705
body: comment_body
706706
)
@@ -1296,6 +1296,12 @@ platform :ios do
12961296
UI.message "Checked out branch `#{git_branch}` as requested by user.\n"
12971297
end
12981298

1299+
def pull_request_number
1300+
# Buildkite sets this env var to the PR number if on a PR, but to 'false' (and not nil) if not on a PR
1301+
pr_num = ENV.fetch('BUILDKITE_PULL_REQUEST', 'false')
1302+
pr_num == 'false' ? nil : Integer(pr_num)
1303+
end
1304+
12991305
# Create a commit with the typical message to use for a version bump
13001306
#
13011307
def commit_version_bump

0 commit comments

Comments
 (0)