mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-23 10:28:56 +08:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d0c5f7955e | ||
|
a2ba194e38 | ||
|
0821518fd9 | ||
|
c8b76ea3f7 | ||
|
bf26498bc4 | ||
|
064f85c156 | ||
|
580b26a94c | ||
|
15e064da79 | ||
|
c61d0fe2b5 | ||
|
c5e1979a6b | ||
|
dc882d2669 | ||
|
f9f0422c72 |
32
README.md
32
README.md
@@ -11,7 +11,7 @@ The following workflow will run `gradle build` using the wrapper from the reposi
|
|||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
// .github/workflows/gradle-build-pr.yml
|
# .github/workflows/gradle-build-pr.yml
|
||||||
name: Run Gradle on PRs
|
name: Run Gradle on PRs
|
||||||
on: pull-request
|
on: pull-request
|
||||||
jobs:
|
jobs:
|
||||||
@@ -92,6 +92,7 @@ Moreover, you can use the following aliases:
|
|||||||
|
|
||||||
| Alias | Selects |
|
| Alias | Selects |
|
||||||
| --- |---|
|
| --- |---|
|
||||||
|
| `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/) |
|
||||||
| `rc` | The current [release candidate](https://gradle.org/release-candidate/) if any, otherwise fallback to `current` |
|
| `rc` | The current [release candidate](https://gradle.org/release-candidate/) if any, otherwise fallback to `current` |
|
||||||
| `nightly` | The latest [nightly](https://gradle.org/nightly/), fails if none. |
|
| `nightly` | The latest [nightly](https://gradle.org/nightly/), fails if none. |
|
||||||
@@ -100,7 +101,7 @@ Moreover, you can use the following aliases:
|
|||||||
This can be handy to, for example, automatically test your build with the next Gradle version once a release candidate is out:
|
This can be handy to, for example, automatically test your build with the next Gradle version once a release candidate is out:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
// .github/workflows/test-gradle-rc.yml
|
# .github/workflows/test-gradle-rc.yml
|
||||||
name: Test latest Gradle RC
|
name: Test latest Gradle RC
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -124,3 +125,30 @@ jobs:
|
|||||||
If your build publishes a [build scan](https://gradle.com/build-scans/) the `gradle-command-action` action will emit the link to the published build scan as an output named `build-scan-url`.
|
If your build publishes a [build scan](https://gradle.com/build-scans/) the `gradle-command-action` action will emit the link to the published build scan as an output named `build-scan-url`.
|
||||||
|
|
||||||
You can then use that link in subsequent actions of your workflow.
|
You can then use that link in subsequent actions of your workflow.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/gradle-build-pr.yml
|
||||||
|
name: Run Gradle on PRs
|
||||||
|
on: pull-request
|
||||||
|
jobs:
|
||||||
|
gradle:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
arguments: build
|
||||||
|
id: gradle
|
||||||
|
- uses: example/action-that-comments-on-the-pr@v0
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
comment: Build failed ${{ steps.gradle.outputs.build-scan-url }}
|
||||||
|
```
|
||||||
|
12
lib/main.js
12
lib/main.js
@@ -44,23 +44,25 @@ run();
|
|||||||
function resolveGradleExecutable(baseDirectory) {
|
function resolveGradleExecutable(baseDirectory) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const gradleVersion = inputOrNull("gradle-version");
|
const gradleVersion = inputOrNull("gradle-version");
|
||||||
if (gradleVersion != null) {
|
if (gradleVersion != null && gradleVersion != "wrapper") {
|
||||||
return provision.gradleVersion(gradleVersion);
|
return path.resolve(yield provision.gradleVersion(gradleVersion));
|
||||||
}
|
}
|
||||||
const gradleExecutable = inputOrNull("gradle-executable");
|
const gradleExecutable = inputOrNull("gradle-executable");
|
||||||
if (gradleExecutable != null) {
|
if (gradleExecutable != null) {
|
||||||
return path.join(baseDirectory, gradleExecutable);
|
return path.resolve(baseDirectory, gradleExecutable);
|
||||||
}
|
}
|
||||||
const wrapperDirectory = inputOrNull("wrapper-directory");
|
const wrapperDirectory = inputOrNull("wrapper-directory");
|
||||||
const executableDirectory = wrapperDirectory != null
|
const executableDirectory = wrapperDirectory != null
|
||||||
? path.join(baseDirectory, wrapperDirectory)
|
? path.join(baseDirectory, wrapperDirectory)
|
||||||
: baseDirectory;
|
: baseDirectory;
|
||||||
return path.join(executableDirectory, gradlew.wrapperFilename());
|
return path.resolve(executableDirectory, gradlew.wrapperFilename());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function resolveBuildRootDirectory(baseDirectory) {
|
function resolveBuildRootDirectory(baseDirectory) {
|
||||||
let buildRootDirectory = inputOrNull("build-root-directory");
|
let buildRootDirectory = inputOrNull("build-root-directory");
|
||||||
return buildRootDirectory == null ? baseDirectory : path.join(baseDirectory, buildRootDirectory);
|
return buildRootDirectory == null
|
||||||
|
? path.resolve(baseDirectory)
|
||||||
|
: path.resolve(baseDirectory, buildRootDirectory);
|
||||||
}
|
}
|
||||||
function parseCommandLineArguments() {
|
function parseCommandLineArguments() {
|
||||||
const input = inputOrNull("arguments");
|
const input = inputOrNull("arguments");
|
||||||
|
12
src/main.ts
12
src/main.ts
@@ -39,13 +39,13 @@ run();
|
|||||||
async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
||||||
|
|
||||||
const gradleVersion = inputOrNull("gradle-version");
|
const gradleVersion = inputOrNull("gradle-version");
|
||||||
if (gradleVersion != null) {
|
if (gradleVersion != null && gradleVersion != "wrapper") {
|
||||||
return provision.gradleVersion(gradleVersion)
|
return path.resolve(await provision.gradleVersion(gradleVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
const gradleExecutable = inputOrNull("gradle-executable");
|
const gradleExecutable = inputOrNull("gradle-executable");
|
||||||
if (gradleExecutable != null) {
|
if (gradleExecutable != null) {
|
||||||
return path.join(baseDirectory, gradleExecutable)
|
return path.resolve(baseDirectory, gradleExecutable)
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperDirectory = inputOrNull("wrapper-directory");
|
const wrapperDirectory = inputOrNull("wrapper-directory");
|
||||||
@@ -53,13 +53,15 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
|||||||
? path.join(baseDirectory, wrapperDirectory)
|
? path.join(baseDirectory, wrapperDirectory)
|
||||||
: baseDirectory;
|
: baseDirectory;
|
||||||
|
|
||||||
return path.join(executableDirectory, gradlew.wrapperFilename());
|
return path.resolve(executableDirectory, gradlew.wrapperFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||||
let buildRootDirectory = inputOrNull("build-root-directory");
|
let buildRootDirectory = inputOrNull("build-root-directory");
|
||||||
return buildRootDirectory == null ? baseDirectory : path.join(baseDirectory, buildRootDirectory);
|
return buildRootDirectory == null
|
||||||
|
? path.resolve(baseDirectory)
|
||||||
|
: path.resolve(baseDirectory, buildRootDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user