Last active
July 5, 2021 17:42
-
-
Save rafaeldelboni/07bfd314c2c92b9501b086982f5c0e7a to your computer and use it in GitHub Desktop.
Test, Build, Deploy Jar on Heroku using Clojure + Deps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
run_tests: | |
strategy: | |
matrix: | |
namespace: [ unit, integration ] | |
operating-system: [ubuntu-latest] | |
runs-on: ${{ matrix.operating-system }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare java | |
uses: actions/[email protected] | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Install clojure tools-deps | |
uses: DeLaGuardo/setup-clojure@master | |
with: | |
tools-deps: 1.10.3.882 | |
- name: Cache Maven packages | |
uses: actions/[email protected] | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Execute clojure code | |
run: clojure -M:test ${{ matrix.namespace }} | |
build_jar: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare java | |
uses: actions/[email protected] | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: Install clojure tools-deps | |
uses: DeLaGuardo/setup-clojure@master | |
with: | |
tools-deps: 1.10.3.882 | |
- name: Cache Maven packages | |
uses: actions/[email protected] | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Generate uberjar | |
run: clojure -X:uberjar | |
- name: Upload uberjar artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: built-uberjar | |
path: service.jar | |
retention-days: 1 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [run_tests, build_jar] | |
steps: | |
- name: Download uberjar artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: built-uberjar | |
- name: Heroku login credentials | |
run: | | |
cat > ~/.netrc <<EOF | |
machine api.heroku.com | |
login $HEROKU_EMAIL | |
password $HEROKU_API_KEY | |
machine git.heroku.com | |
login $HEROKU_EMAIL | |
password $HEROKU_API_KEY | |
EOF | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} | |
- name: Heroku CLI Plugin for Java | |
run: heroku plugins:install java | |
- name: Heroku Deploy jar | |
run: heroku deploy:jar service.jar --app $HEROKU_APP_NAME | |
env: | |
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:paths ["src" "resources"] | |
:deps {org.clojure/clojure {:mvn/version "1.10.3"}} | |
:aliases | |
{:test {:extra-paths ["test"] | |
:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.861"}} | |
:main-opts ["-m" "kaocha.runner"]} | |
:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.245"}} | |
:exec-fn hf.depstar/uberjar | |
:exec-args {:jar "service.jar" | |
:aot true | |
:main-class microservice-boilerplate.server}}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#kaocha/v1 | |
{:tests [{:id :unit | |
:test-paths ["test/unit"]} | |
{:id :integration | |
:test-paths ["test/integration"]}] | |
:reporter kaocha.report/tap} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sources: