Skip to content

Commit

Permalink
For #487 - pass secrets to Earthly
Browse files Browse the repository at this point in the history
  • Loading branch information
binkley committed May 22, 2024
1 parent e8d518a commit 004a3d0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-earthly-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
version: "latest"

- name: Clone repository
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Restore Gradle caches
uses: actions/cache@master
Expand All @@ -48,7 +48,7 @@ jobs:
${{ runner.os }}-
- name: Build and test
run: earthly +build-with-gradle
run: earthly --secret OWASP_NVD_API_KEY +build-with-gradle

- name: Execute run script
run: earthly +run-with-gradle
run: earthly --secret OWASP_NVD_API_KEY +run-with-gradle
6 changes: 3 additions & 3 deletions .github/workflows/ci-earthly-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
version: "latest"

- name: Clone repository
uses: actions/checkout@master
uses: actions/checkout@v4

- name: Restore Maven caches
uses: actions/cache@master
Expand All @@ -47,10 +47,10 @@ jobs:
${{ runner.os }}-
- name: Build and test
run: earthly +build-with-maven
run: earthly --secret OWASP_NVD_API_KEY +build-with-maven

- name: Execute run script
run: earthly +run-with-maven
run: earthly --secret OWASP_NVD_API_KEY +run-with-maven

- name: Generate coverage badge
# if: ${{ github.ref == 'refs/head/master' }}
Expand Down
4 changes: 2 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-with-gradle:
COPY build.gradle .
COPY config config
COPY src src
RUN ./gradlew clean build
RUN --secret OWASP_NVD_API_KEY ./gradlew clean build

run-with-gradle:
FROM +build-with-gradle
Expand All @@ -23,7 +23,7 @@ build-with-maven:
COPY pom.xml .
COPY config config
COPY src src
RUN ./mvnw --no-transfer-progress clean verify
RUN --secret OWASP_NVD_API_KEY ./mvnw --no-transfer-progress clean verify
SAVE ARTIFACT --keep-ts target/site/jacoco/jacoco.csv AS LOCAL target/site/jacoco/jacoco.csv

run-with-maven:
Expand Down
22 changes: 17 additions & 5 deletions build-as-ci-does.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ! command -v earthly >/dev/null; then
exit 2
fi

set -e
set -e # Fail on first failed command

# Provide nicer console output via formatting and color
# See https://github.com/binkley/shell/blob/master/color/color.sh
Expand All @@ -14,12 +14,24 @@ printf -v pbold "\e[1m"

echo
echo "${pbold}BUILD WITH GRADLE UNDER EARTHLY${preset}"
earthly +build-with-gradle
earthly --secret OWASP_NVD_API_KEY +build-with-gradle
echo "${pbold}RUN WITH GRADLE UNDER EARTHLY${preset}"
earthly +run-with-gradle
earthly --secret OWASP_NVD_API_KEY +run-with-gradle

echo
echo "${pbold}BUILD WITH GRADLE DIRECTLY${preset}"
./gradlew clean build
echo "${pbold}RUN WITH GRADLE DIRECTLY${preset}"
./run-with-gradle.sh

echo
echo "${pbold}BUILD WITH MAVEN UNDER EARTHLY${preset}"
earthly +build-with-maven
earthly --secret OWASP_NVD_API_KEY +build-with-maven
echo "${pbold}RUN WITH MAVEN UNDER EARTHLY${preset}"
earthly +run-with-maven
earthly --secret OWASP_NVD_API_KEY +run-with-maven

echo
echo "${pbold}BUILD WITH MAVEN DIRECTLY${preset}"
./mvnw clean verify
echo "${pbold}RUN WITH MAVEN DIRECTLY${preset}"
./run-with-maven.sh

0 comments on commit 004a3d0

Please sign in to comment.