diff --git a/.drone.star b/.drone.star index b82577b2b..25420c3d3 100644 --- a/.drone.star +++ b/.drone.star @@ -357,7 +357,12 @@ def uploadScanResults(ctx): "SONAR_PULL_REQUEST_KEY": "%s" % (ctx.build.ref.replace("refs/pull/", "").split("/")[0]), }) - repo_slug = ctx.build.source_repo if ctx.build.source_repo else ctx.repo.slug + fork_handling = [] + if ctx.build.source_repo != "" and ctx.build.source_repo != ctx.repo.slug: + fork_handling = [ + "git remote add fork https://github.com/%s.git" % (ctx.build.source_repo), + "git fetch fork", + ] return { "kind": "pipeline", @@ -375,9 +380,13 @@ def uploadScanResults(ctx): "name": "clone", "image": "alpine/git:latest", "commands": [ - "git clone https://github.com/%s.git ." % (repo_slug), - "git checkout $DRONE_COMMIT", - ], + # Always use the owncloud/ocis repository as base to have an up to date default branch. + # This is needed for the skipIfUnchanged step, since it references a commit on master (which could be absent on a fork) + "git clone https://github.com/%s.git ." % (ctx.repo.slug), + ] + fork_handling + + [ + "git checkout $DRONE_COMMIT", + ], }, ] + skipIfUnchanged(ctx, "unit-tests") + [ {