From 62826d3b13ae3a17a75d59444f61955e798816b4 Mon Sep 17 00:00:00 2001 From: Jonas Hecht Date: Sun, 14 Mar 2021 20:51:35 +0100 Subject: [PATCH 1/3] Refactor pipelines for a more GH Actions building block design --- .github/workflows/native-image-compile.yml | 44 +++++++++------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/native-image-compile.yml b/.github/workflows/native-image-compile.yml index 50e1737..8403221 100644 --- a/.github/workflows/native-image-compile.yml +++ b/.github/workflows/native-image-compile.yml @@ -5,59 +5,49 @@ on: [push] jobs: native-image-compile-on-host: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - - name: Install GraalVM, Maven, Native Image & Run Maven build + - name: Install GraalVM with SDKMAN run: | - echo 'Install GraalVM with SDKMAN' curl -s "https://get.sdkman.io" | bash source "$HOME/.sdkman/bin/sdkman-init.sh" sdk install java 20.3.1.2.r11-grl - - echo 'Check if GraalVM was installed successfully' java -version - echo 'Install GraalVM Native Image' + - name: Install GraalVM Native Image + run: | gu install native-image - - echo 'Check if Native Image was installed properly' native-image --version - echo 'Install Maven, that uses GraalVM for later builds' + - name: Install Maven, that uses GraalVM for later builds + run: | source "$HOME/.sdkman/bin/sdkman-init.sh" sdk install maven - - echo 'Show Maven using GraalVM JDK' mvn --version - echo 'Run GraalVM Native Image compilation of Spring Boot App (Maven version instead of ./compile.sh)' - mvn -B clean package -P native --no-transfer-progress + - name: Run GraalVM Native Image compilation of Spring Boot App (Maven version instead of ./compile.sh) + run: mvn -B clean package -P native --no-transfer-progress native-image-compile-in-docker: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - - name: Build Native Image with Docker and Release to Heroku & Docker Hub - run: | - echo 'Login into Heroku Container Registry first, so that we can push our Image later' - echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin registry.heroku.com + - name: Login into Heroku Container Registry first, so that we can push our Image later + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin registry.heroku.com - echo 'Compile Native Image using Docker' - docker build . --tag=registry.heroku.com/spring-boot-graal/web + - name: Compile Native Image using Docker + run: docker build . --tag=registry.heroku.com/spring-boot-graal/web - echo 'Push to Heroku Container Registry' - docker push registry.heroku.com/spring-boot-graal/web + - name: Push to Heroku Container Registry + run: docker push registry.heroku.com/spring-boot-graal/web - echo 'Release Dockerized Native Spring Boot App on Heroku' - ./heroku-release.sh spring-boot-graal + - name: Release Dockerized Native Spring Boot App on Heroku + run: ./heroku-release.sh spring-boot-graal - echo 'Push to Docker Hub also, since automatic Builds there dont have anough RAM to do a docker build' + - name: Push to Docker Hub also, since automatic Builds there dont have anough RAM to do a docker build + run: | echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin docker tag registry.heroku.com/spring-boot-graal/web jonashackt/spring-boot-graalvm:latest docker push jonashackt/spring-boot-graalvm:latest - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file From cf7c4ca53dddd6d75b5982f3fcff20ef6e47a369 Mon Sep 17 00:00:00 2001 From: Jonas Hecht Date: Sun, 14 Mar 2021 20:55:05 +0100 Subject: [PATCH 2/3] Sourcing SDKMAN for gu install also. Added Caching for SDKMAN install dir. --- .github/workflows/native-image-compile.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/native-image-compile.yml b/.github/workflows/native-image-compile.yml index 8403221..c6a70dc 100644 --- a/.github/workflows/native-image-compile.yml +++ b/.github/workflows/native-image-compile.yml @@ -8,6 +8,14 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache SDKMAN installation + uses: actions/cache@v2 + with: + path: ~/.sdkman + key: ${{ runner.os }}-sdkman-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-sdkman- + - name: Install GraalVM with SDKMAN run: | curl -s "https://get.sdkman.io" | bash @@ -17,6 +25,7 @@ jobs: - name: Install GraalVM Native Image run: | + source "$HOME/.sdkman/bin/sdkman-init.sh" gu install native-image native-image --version From af4197278b32c7da7ecdc9743df318bc1f0f3293 Mon Sep 17 00:00:00 2001 From: Jonas Hecht Date: Sun, 14 Mar 2021 20:59:27 +0100 Subject: [PATCH 3/3] Sourcing SDKMAN for mvn build also. --- .github/workflows/native-image-compile.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/native-image-compile.yml b/.github/workflows/native-image-compile.yml index c6a70dc..28b24a4 100644 --- a/.github/workflows/native-image-compile.yml +++ b/.github/workflows/native-image-compile.yml @@ -36,7 +36,9 @@ jobs: mvn --version - name: Run GraalVM Native Image compilation of Spring Boot App (Maven version instead of ./compile.sh) - run: mvn -B clean package -P native --no-transfer-progress + run: | + source "$HOME/.sdkman/bin/sdkman-init.sh" + mvn -B clean package -P native --no-transfer-progress native-image-compile-in-docker: runs-on: ubuntu-latest