From ec81bc3bb2eb987796e65a73db3092eb67989a9e Mon Sep 17 00:00:00 2001 From: Whitney O'Meara Date: Wed, 24 Jan 2024 17:39:20 +0000 Subject: [PATCH] Added maven repo access token configuration for github actions --- .github/workflows/settings.xml | 23 +++++++++++++++++++++++ .github/workflows/tests.yaml | 16 +++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/settings.xml diff --git a/.github/workflows/settings.xml b/.github/workflows/settings.xml new file mode 100644 index 0000000..d8be2eb --- /dev/null +++ b/.github/workflows/settings.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + github-datawave + ${env.USER_NAME} + ${env.ACCESS_TOKEN} + + + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ddf7927..284ca14 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,11 +31,13 @@ jobs: ${{ runner.os }}-maven- - name: Format code run: | - mvn -V -B -e clean formatter:format sortpom:sort -Pautoformat + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e clean formatter:format sortpom:sort -Pautoformat git status git diff-index --quiet HEAD || (echo "Error! There are modified files after formatting." && false) env: MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true" + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Build the code and run the unit/integration tests. build-and-test: @@ -56,9 +58,11 @@ jobs: ${{ runner.os }}-maven-format- ${{ runner.os }}-maven- - name: Build and Run Unit Tests - run: mvn -V -B -e -Ddist clean verify + run: mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Ddist clean verify env: MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true" + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Here's an example of how you'd deploy the image to the github package registry. # We don't want to do this by default since packages on github cannot be deleted @@ -68,11 +72,13 @@ jobs: # env: # IMAGE_REGISTRY: "docker.pkg.github.com" # IMAGE_USERNAME: "NationalSecurityAgency" + # USER_NAME: ${{ secrets.USER_NAME }} + # ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # run: | # # Set up env vars - # IMAGE_NAME=$(mvn -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec) - # IMAGE_PREFIX=$(mvn -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${docker.image.prefix}' exec:exec) - # IMAGE_TAG=$(mvn -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec) + # IMAGE_NAME=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec) + # IMAGE_PREFIX=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${docker.image.prefix}' exec:exec) + # IMAGE_TAG=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec) # REMOTE_IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_USERNAME}/${IMAGE_PREFIX}${IMAGE_NAME}" # # Log in to the package registry # echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com --username ${GITHUB_ACTOR} --password-stdin