Skip to content

Commit 84f8b33

Browse files
committed
ci-build: fix project fork detection
Let's make BUILD_REPOSITORY be the complete SCM URL as specified in the pom.xml. That way, other ci-setup-<foo> scripts can set the URL according to their platform as well, and we compare the whole string.
1 parent d26711d commit 84f8b33

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

ci-build.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
#
44
# ci-build.sh - A script to build and/or release SciJava-based projects
5-
# automatically using a continuous integration
6-
# service.
5+
# automatically using a continuous integration service.
76
#
8-
# Required environment variables:
9-
# BUILD_REPOSITORY - the repository slug (org/repo) running the current build
7+
# Optional environment variables:
8+
# BUILD_REPOSITORY - the repository URL running the current build
109

1110
dir="$(dirname "$0")"
1211

@@ -77,20 +76,18 @@ EOL
7776

7877
# Determine whether deploying will be possible.
7978
deployOK=
80-
ciURL=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${project.ciManagement.url}' --non-recursive validate exec:exec 2>&1)
79+
scmURL=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${project.scm.url}' --non-recursive validate exec:exec 2>&1)
8180

8281
if [ $? -ne 0 ]; then
8382
echo "No deploy -- could not extract ciManagement URL"
8483
echo "Output of failed attempt follows:"
85-
echo "$ciURL"
84+
echo "$scmURL"
8685
else
87-
ciRepo=${ciURL##*/}
88-
ciPrefix=${ciURL%/*}
89-
ciOrg=${ciPrefix##*/}
86+
scmRepo=${scmURL##*/}
9087
if [ ! "$SIGNING_ASC" ] || [ ! "$GPG_KEY_NAME" ] || [ ! "$GPG_PASSPHRASE" ] || [ ! "$MAVEN_PASS" ] || [ ! "$OSSRH_PASS" ]; then
9188
echo "No deploy -- secure environment variables not available"
92-
elif [ "$BUILD_REPOSITORY" != "$ciOrg/$ciRepo" ]; then
93-
echo "No deploy -- repository fork: $BUILD_REPOSITORY != $ciOrg/$ciRepo"
89+
elif [ "$BUILD_REPOSITORY" -a "$BUILD_REPOSITORY" != "$scmRepo" ]; then
90+
echo "No deploy -- repository fork: $BUILD_REPOSITORY != $scmRepo"
9491
else
9592
echo "All checks passed for artifact deployment"
9693
deployOK=1

ci-setup-github-actions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# ci-setup-github-actions.sh - Set CI-related environment variables from GitHub Actions.
55
#
66

7-
echo "BUILD_REPOSITORY=${GITHUB_REPOSITORY}"
7+
echo "BUILD_REPOSITORY=https://github.com/${GITHUB_REPOSITORY}"
88
echo "BUILD_OS=${RUNNER_OS}"
99

10-
echo "BUILD_REPOSITORY=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
10+
echo "BUILD_REPOSITORY=https://github.com/${GITHUB_REPOSITORY}" >> $GITHUB_ENV
1111
echo "BUILD_OS=${RUNNER_OS}" >> $GITHUB_ENV

0 commit comments

Comments
 (0)