diff --git a/.github/workflows/sbt-matrix.yml b/.github/workflows/sbt-matrix.yml index 4866fde..9ad800f 100644 --- a/.github/workflows/sbt-matrix.yml +++ b/.github/workflows/sbt-matrix.yml @@ -9,9 +9,29 @@ on: scala: type: string required: true + include: + type: string + required: false + default: "[]" + exclude: + type: string + required: false + default: "[]" cmd: type: string required: true + env: + type: string + required: false + default: "" + cache-key: + type: string + required: false + default: "" + cache-path: + type: string + required: false + default: "" jobs: cmd: @@ -22,6 +42,8 @@ jobs: matrix: java: ${{ fromJson(inputs.java) }} scala: ${{ fromJson(inputs.scala) }} + include: ${{ fromJson(inputs.include) }} + exclude: ${{ fromJson(inputs.exclude) }} steps: - name: Checkout uses: actions/checkout@v2 @@ -29,9 +51,20 @@ jobs: # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves fetch-depth: 0 + - name: Set ENV variables + if: inputs.env != '' + run: echo '${{ inputs.env }}' >> $GITHUB_ENV + - name: Coursier Cache uses: coursier/cache-action@v6.3 + - name: Custom Cache + uses: actions/cache@v2 + if: ${{ inputs.cache-key != '' && inputs.cache-path != '' }} + with: + key: ${{ inputs.cache-key }} + path: ${{ inputs.cache-path }} + - name: Install AdoptOpenJDK uses: coursier/setup-action@v1.1.2 with: diff --git a/.github/workflows/sbt.yml b/.github/workflows/sbt.yml index 989604f..c4d9a3e 100644 --- a/.github/workflows/sbt.yml +++ b/.github/workflows/sbt.yml @@ -7,9 +7,17 @@ on: type: string required: false default: 8 + scala: + type: string + required: false + default: "" cmd: + type: string required: true + env: type: string + required: false + default: "" cache-key: type: string required: false @@ -30,6 +38,10 @@ jobs: # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves fetch-depth: 0 + - name: Set ENV variables + if: inputs.env != '' + run: echo '${{ inputs.env }}' >> $GITHUB_ENV + - name: Coursier Cache uses: coursier/cache-action@v6.3 @@ -47,3 +59,5 @@ jobs: - name: Run sbt command run: ${{ inputs.cmd }} + env: + SCALA_VERSION: ${{ inputs.scala }} diff --git a/README.md b/README.md index cbb4c9c..d98d947 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,20 @@ This workflow is used for running a single SBT task. It can to use for running a |------------|-------|--------------------|---------|----------------------| | cmd | 1.0.0 | :exclamation: | - | Running command | | java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | +| scala | 1.0.0 | :heavy_minus_sign: | '' | _Scala_ version | | cache-key | 1.0.0 | :heavy_minus_sign: | '' | Key of custom cache | | cache-path | 1.0.0 | :heavy_minus_sign: | '' | Path of custom cache | +| env | 1.0.0 | :heavy_minus_sign: | '' | Custom ENV vars | **How to use**: ```yaml uses: playframework/.github/.github/workflows/sbt.yml@v1 with: - cmd: sbt test + cmd: sbt "-Dvar1=$VAR_1" "-Dvar2=$VAR_2" ++$SCALA_VERSION test + env: | + VAR_1=value + VAR_2=value ``` ### Java/Scala matrix SBT task @@ -53,11 +58,17 @@ This workflow is used for running an SBT task on matrix of Java/Scala versions. **Parameters**: -| Parameter | Since | Required | Default | Description | -|-----------|-------|-----------------|---------|--------------------| -| cmd | 1.0.0 | :exclamation: | - | Running command | -| java | 1.0.0 | :exclamation: | - | _AdoptJDK_ version | -| scala | 1.0.0 | :exclamation: | - | _Scala_ version | +| Parameter | Since | Required | Default | Description | +|------------|-------|--------------------|---------|----------------------| +| cmd | 1.0.0 | :exclamation: | - | Running command | +| java | 1.0.0 | :exclamation: | - | _AdoptJDK_ version | +| scala | 1.0.0 | :exclamation: | - | _Scala_ version | +| include | 1.0.0 | :heavy_minus_sign: | [] | Matrix include's | +| exclude | 1.0.0 | :heavy_minus_sign: | [] | Matrix exclude's | +| cache-key | 1.0.0 | :heavy_minus_sign: | '' | Key of custom cache | +| cache-path | 1.0.0 | :heavy_minus_sign: | '' | Path of custom cache | +| env | 1.0.0 | :heavy_minus_sign: | '' | Custom ENV vars | + **How to use**: @@ -68,7 +79,10 @@ with: [ "11", "8" ] scala: >- [ "2.12.15", "2.13.8", "3.0.2" ] - cmd: sbt test + cmd: sbt "-Dvar1=$VAR_1" "-Dvar2=$VAR_2" ++$SCALA_VERSION test + env: | + VAR_1=value + VAR_2=value ``` ### Publishing to Sonatype