Skip to content

Commit d196f97

Browse files
committed
OAK-9500 Deploy Snapshot artifacts from trunk to Apache Nexus
1 parent 26e6eeb commit d196f97

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,40 @@ jobs:
3535
java-version: 11
3636
distribution: temurin
3737
cache: maven
38+
server-id: apache.snapshots.https # Value of the distributionManagement/repository/id field of the pom.xml
39+
server-username: MAVEN_APACHE_NEXUS_USERNAME # env variable for username in deploy
40+
server-password: MAVEN_APACHE_NEXUS_PASSWORD # env variable for token in deploy
41+
# sets environment variables to be used in subsequent steps: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
42+
- name: Set environment variables
43+
shell: bash
44+
run: |
45+
if [ "${{github.ref}}" = "refs/pull/1935/merge" ] && [ "${{github.event_name}}" = "pull_request" ] && [ "${{github.repository_owner}}" = "apache" ]; then
46+
echo 'Running on main branch of the canonical repo'
47+
echo "MVN_ADDITIONAL_OPTS=-DdeployAtEnd=true" >> $GITHUB_ENV
48+
echo "MVN_GOAL=deploy" >> $GITHUB_ENV
49+
echo "MAVEN_APACHE_NEXUS_USERNAME=${{ secrets.NEXUS_USER }}" >> $GITHUB_ENV
50+
echo "MAVEN_APACHE_NEXUS_PASSWORD=${{ secrets.NEXUS_PW }}" >> $GITHUB_ENV
51+
else
52+
echo 'Running outside main branch/canonical repo'
53+
echo "MVN_ADDITIONAL_OPTS=" >> $GITHUB_ENV
54+
echo "MVN_GOAL=install" >> $GITHUB_ENV
55+
fi
3856
- name: Build
3957
# executing ITs requires installing artifacts to the local repository
40-
run: mvn -B install -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
58+
run: mvn -B ${{ env.MVN_GOAL }} ${{ env.MVN_ADDITIONAL_OPTS }} -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
4159
- name: Upload build result
4260
uses: actions/upload-artifact@v4
4361
with:
4462
name: compiled-classes-and-coverage
45-
# compare with https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/java/#java-analysis-and-bytecode
63+
# compare with https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/java/#java-analysis-and-bytecode
4664
path: |
4765
**/target/**/*.class
4866
**/target/site/jacoco*/*.xml
67+
4968
# execute analysis in a separate job for better visualization and usage of matrix builds
5069
# https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarscanner-for-maven/#invoking-the-goal
5170
sonar:
52-
name: SonarCloud Analysis
71+
name: SonarQube Analysis
5372
runs-on: ubuntu-latest
5473
needs: build
5574
# not supported on forks, https://portal.productboard.com/sonarsource/1-sonarqube-cloud/c/50-sonarcloud-analyzes-external-pull-request
@@ -68,13 +87,13 @@ jobs:
6887
uses: actions/download-artifact@v4
6988
with:
7089
name: compiled-classes-and-coverage
71-
- name: Cache SonarCloud packages
90+
- name: Cache SonarQube packages
7291
uses: actions/cache@v4
7392
with:
7493
path: ~/.sonar/cache
7594
key: ${{ runner.os }}-sonar
7695
restore-keys: ${{ runner.os }}-sonar
77-
- name: Analyze with SonarCloud
96+
- name: Analyze with SonarQube
7897
env:
7998
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
8099
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

0 commit comments

Comments
 (0)