Skip to content

Commit 1954573

Browse files
authored
ci(swift): Fix Swift integration failure for PRs from external contributors (#17577)
* ci(swift): use GITHUB_REPOSITORY env to construct Swift package URL dynamically to handle forked repositories * chore: print reposlug * add env to store repository name * add script to print PR info * reference PR_HEAD_REPO * reference PR_HEAD_REPO * clean up code * clean up code
1 parent eeba962 commit 1954573

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.github/workflows/all_plugins.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
timeout-minutes: 30
128128
env:
129129
FLUTTER_DEPENDENCIES: "cloud_firestore firebase_remote_config cloud_functions firebase_database firebase_auth firebase_storage firebase_analytics firebase_messaging firebase_app_check firebase_in_app_messaging firebase_performance firebase_crashlytics firebase_ml_model_downloader firebase_app_installations"
130+
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
130131
steps:
131132
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
132133
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff

.github/workflows/scripts/swift-integration.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ Future<void> updatePackageSwiftForPackage(String packageName, String branch) asy
8181
multiLine: true
8282
);
8383

84+
final headRepo = Platform.environment['PR_HEAD_REPO'];
85+
final baseRepo = Platform.environment['GITHUB_REPOSITORY'];
86+
87+
// handles forked repositories
88+
final repoSlug = headRepo != baseRepo ? headRepo : baseRepo;
89+
8490
// Replace with branch dependency
85-
final branchDependency = '.package(url: "https://github.com/firebase/flutterfire", branch: "$branch")';
91+
final branchDependency = '.package(url: "https://github.com/$repoSlug", branch: "$branch")';
8692

8793
if (exactVersionPattern.hasMatch(content)) {
8894
updatedContent = content.replaceAll(exactVersionPattern, branchDependency);

0 commit comments

Comments
 (0)