@@ -107,39 +107,47 @@ jobs:
107107 dashLicenseToolJar=$(ls ~/.m2/repository/org/eclipse/dash/org.eclipse.dash.licenses/1.1.0/org.eclipse.dash.licenses-*.jar | tail -n 1)
108108 npmArgs=" --no-bin-links --ignore-scripts"
109109 dashArgs="-excludeSources local -summary $savePWD/target/dash/npm-review-summary"
110- exitStatus=0
111- if [ ${{ env.request-review }} ]; then
112- # Add "-project <Project Name> -token <Token>" here when a review is required
113- dashArgs="$dashArgs -review -project $projectId -token $gitlabAPIToken"
110+ reviewArgs="-review -project $projectId -token $gitlabAPIToken"
111+ requestReview="${{ env.request-review }}"
112+ # When a review was requested explicitly (e.g. '/request-license-review' comment), ask for it right away.
113+ if [ "$requestReview" ]; then
114+ dashArgs="$dashArgs $reviewArgs"
114115 fi
115116 #
116117 # Check NPM dependency licenses in main WildWebDeveloper project
117118 #
118119 echo ""
119120 echo "------ Checking project [org.eclipse.wildwebdeveloper] ------"
120121 java -jar $dashLicenseToolJar $dashArgs org.eclipse.wildwebdeveloper/package-lock.json
121- currentStatus=$?
122- if [[ $currentStatus != 0 ]]; then
123- exitStatus=$(($exitStatus + $currentStatus)) # Save for future
124- fi
122+ exitStatus=$?
125123 cd $savePWD
126-
124+
125+ # If unvetted content was found and no review was requested yet, request one automatically,
126+ # i.e. re-run the check with '-review' as if a committer had commented '/request-license-review'.
127+ if [[ $exitStatus != 0 && -z "$requestReview" ]]; then
128+ echo ""
129+ if [ -n "$gitlabAPIToken" ]; then
130+ echo "Some contents are not vetted - automatically requesting a license review"
131+ requestReview=1
132+ echo "request-review=1" >> $GITHUB_ENV
133+ java -jar $dashLicenseToolJar $dashArgs $reviewArgs org.eclipse.wildwebdeveloper/package-lock.json
134+ cd $savePWD
135+ else
136+ echo "Some contents requires a review but no API token is available to request it automatically"
137+ echo "Committers can request a review by commenting '/request-license-review'"
138+ fi
139+ fi
140+
127141 echo ""
128142 if [[ $exitStatus == 0 ]]; then # All licenses are vetted
129- # echo "::set-output name=build-succeeded::$(echo 1)"
130143 echo "build-succeeded=1" >> $GITHUB_OUTPUT
131144 echo "All licenses are vetted"
132145 else
133- # echo "::set-output name=build-succeeded::$(echo 0)"
134146 echo "build-succeeded=0" >> $GITHUB_OUTPUT
135- if [ ${{ env.request-review }} ]; then
136- echo "Some contents requires a review"
137- echo ""
138- echo "The NPM dependency License Check review summary is saved in 'target/dash/npm-review-summary'"
139- else
140- echo "Committers can request a review by commenting '/request-license-review'"
141- exit 1
142- fi
147+ echo "Some contents requires a review"
148+ echo "The NPM dependency License Check review summary is saved in 'target/dash/npm-review-summary'"
149+ # Fail the check so the PR is not merged while reviews are pending; re-run once the reviews have concluded.
150+ exit 1
143151 fi
144152 echo ""
145153
0 commit comments