From 7f71c9bc4d5b16418e365c9899b138928a222375 Mon Sep 17 00:00:00 2001 From: Pat Garrity Date: Sun, 17 Mar 2024 10:00:35 -0500 Subject: [PATCH] Updates for credential testing --- .forgejo/workflows/build.yaml | 5 +++-- project/plugins.sbt | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 9b36d39..5d3408b 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -4,8 +4,9 @@ jobs: runs-on: docker container: image: registry.garrity.co:8443/gs/ci-scala:latest + env: + GS_MAVEN_USER: ${{ vars.GS_MAVEN_USER }} + GS_MAVEN_TOKEN: ${{ vars.GS_MAVEN_TOKEN }} steps: - uses: actions/checkout@v4 - - run: cat /home/builder/.sbt/.credentials - - run: echo "password=${{ secrets.GS_MAVEN_TOKEN }}" >> "/home/builder/.sbt/.credentials" - run: sbt test diff --git a/project/plugins.sbt b/project/plugins.sbt index 36bb8cd..f95b86c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,27 @@ -credentials += Credentials(Path.userHome / ".sbt" / ".credentials") +def selectCredentials(): Credentials = + if (Path.userHome.exists()) + Credentials(Path.userHome / ".sbt" / ".credentials") + else + Credentials.apply( + realm = "Reposilite", + host = "maven.garrity.co", + userName = sys.env + .get("GS_MAVEN_USER") + .getOrElse( + throw new RuntimeException( + "You must either provide ~/.sbt/.credentials or specify the GS_MAVEN_USER environment variable." + ) + ), + passwd = sys.env + .get("GS_MAVEN_TOKEN") + .getOrElse( + throw new RuntimeException( + "You must either provide ~/.sbt/.credentials or specify the GS_MAVEN_TOKEN environment variable." + ) + ) + ) + +credentials += selectCredentials() externalResolvers := Seq( "Garrity Software Mirror" at "https://maven.garrity.co/releases",