README improvements

Upgrade checkout to v3.
setup-java:
 Upgrade to v3.
 Always specify distribution.
upload-artifact:
 Upgrade to v3.
 Add if-no-files-found: error.
Upgrade github-script to v6.
Formatting.
This commit is contained in:
Margen67 2022-05-18 17:14:21 -07:00
parent 557c94c831
commit 71d0cf002c

View file

@ -19,8 +19,8 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: temurin distribution: temurin
java-version: 11 java-version: 11
@ -34,10 +34,9 @@ jobs:
## Why use the `gradle-build-action`? ## Why use the `gradle-build-action`?
It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v2` action provides a simple way to cache Gradle dependencies. It is possible to directly invoke Gradle in your workflow, and the `actions/setup-java@v3` action provides a simple way to cache Gradle dependencies.
However, the `gradle-build-action` offers a number of advantages over this approach: However, the `gradle-build-action` offers a number of advantages over this approach:
- Easily [run the build with different versions of Gradle](#download-install-and-use-a-specific-gradle-version) using the `gradle-version` parameter. Gradle distributions are automatically downloaded and cached. - Easily [run the build with different versions of Gradle](#download-install-and-use-a-specific-gradle-version) using the `gradle-version` parameter. Gradle distributions are automatically downloaded and cached.
- More sophisticated and more efficient caching of Gradle User Home between invocations, compared to `setup-java` and most custom configurations using `actions/cache`. [More details below](#caching). - More sophisticated and more efficient caching of Gradle User Home between invocations, compared to `setup-java` and most custom configurations using `actions/cache`. [More details below](#caching).
- Detailed reporting of cache usage and cache configuration options allow you to [optimize the use of the GitHub actions cache](#optimizing-cache-effectiveness). - Detailed reporting of cache usage and cache configuration options allow you to [optimize the use of the GitHub actions cache](#optimizing-cache-effectiveness).
@ -46,7 +45,7 @@ However, the `gradle-build-action` offers a number of advantages over this appro
The `gradle-build-action` is designed to provide these benefits with minimal configuration. The `gradle-build-action` is designed to provide these benefits with minimal configuration.
These features work both when Gradle is executed via the `gradle-build-action` and for any Gradle execution in subsequent steps. These features work both when Gradle is executed via the `gradle-build-action` and for any Gradle execution in subsequent steps.
When using `gradle-build-action` we recommend that you _not_ use `actions/cache` or `actions/setup-java@v2` to explicitly cache the Gradle User Home. Doing so may interfere with the caching provided by this action. When using `gradle-build-action` we recommend that you _not_ use `actions/cache` or `actions/setup-java@v3` to explicitly cache the Gradle User Home. Doing so may interfere with the caching provided by this action.
## Use a specific Gradle version ## Use a specific Gradle version
@ -64,7 +63,7 @@ The `gradle-version` parameter can be set to any valid Gradle version.
Moreover, you can use the following aliases: Moreover, you can use the following aliases:
| Alias | Selects | | Alias | Selects |
| --- |---| | --- | --- |
| `wrapper` | The Gradle wrapper's version (default, useful for matrix builds) | | `wrapper` | The Gradle wrapper's version (default, useful for matrix builds) |
| `current` | The current [stable release](https://gradle.org/install/) | | `current` | The current [stable release](https://gradle.org/install/) |
| `release-candidate` | The current [release candidate](https://gradle.org/release-candidate/) if any, otherwise fallback to `current` | | `release-candidate` | The current [release candidate](https://gradle.org/release-candidate/) if any, otherwise fallback to `current` |
@ -77,14 +76,15 @@ This can be handy to automatically verify your build works with the latest relea
name: Test latest Gradle RC name: Test latest Gradle RC
on: on:
schedule: schedule:
- cron: 0 0 * * * # daily - cron: '0 0 * * *' # daily
jobs: jobs:
gradle-rc: gradle-rc:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: temurin
java-version: 11 java-version: 11
- uses: gradle/gradle-build-action@v2 - uses: gradle/gradle-build-action@v2
with: with:
@ -108,9 +108,10 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: temurin
java-version: 11 java-version: 11
- name: Setup and execute Gradle 'test' task - name: Setup and execute Gradle 'test' task
@ -302,7 +303,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout project sources - name: Checkout project sources
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2 uses: gradle/gradle-build-action@v2
- name: Run build with Gradle wrapper - name: Run build with Gradle wrapper
@ -311,7 +312,8 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: build-reports name: build-reports
path: build/reports/ path: build/reports
if-no-files-found: error
``` ```
## Build scans ## Build scans
@ -331,17 +333,17 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout project sources - name: Checkout project sources
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2 uses: gradle/gradle-build-action@v2
- name: Run build with Gradle wrapper - name: Run build with Gradle wrapper
id: gradle id: gradle
run: ./gradlew build --scan run: ./gradlew build --scan
- name: "Add build scan URL as PR comment" - name: Add build scan URL as PR comment
uses: actions/github-script@v5 uses: actions/github-script@v6
if: github.event_name == 'pull_request' && failure() if: github.event_name == 'pull_request' && failure()
with: with:
github-token: ${{secrets.GITHUB_TOKEN}} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
github.rest.issues.createComment({ github.rest.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,