mirror of
https://github.com/gradle/actions.git
synced 2025-04-20 17:59:19 +08:00
Provision latest Gradle for cache-cleanup
To cleanup Gradle User Home, a Gradle build must be executed. Newer Gradle versions are able to cleanup the home directories of older versions, but not vice-versa. With this change, the latest version of Gradle is automatically provisioned in order to run Gradle User Home cleanup. This ensures a consistent version of Gradle is used for cleanup, and fixes #33 where Gradle is not pre-installed on a custom runner.
This commit is contained in:
parent
b9abb7b195
commit
169bec5d8b
@ -1,8 +1,8 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as glob from '@actions/glob'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import {provisionAndMaybeExecute} from '../execution/gradle'
|
||||
|
||||
export class CacheCleaner {
|
||||
private readonly gradleUserHome: string
|
||||
@ -42,10 +42,16 @@ export class CacheCleaner {
|
||||
)
|
||||
fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}')
|
||||
|
||||
const gradleCommand = `gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet -DGITHUB_DEPENDENCY_GRAPH_ENABLED=false noop`
|
||||
await exec.exec(gradleCommand, [], {
|
||||
cwd: cleanupProjectDir
|
||||
})
|
||||
await provisionAndMaybeExecute('current', cleanupProjectDir, [
|
||||
'-g',
|
||||
this.gradleUserHome,
|
||||
'--quiet',
|
||||
'--no-daemon',
|
||||
'--no-scan',
|
||||
'--build-cache',
|
||||
'-DGITHUB_DEPENDENCY_GRAPH_ENABLED=false',
|
||||
'noop'
|
||||
])
|
||||
}
|
||||
|
||||
private async ageAllFiles(fileName = '*'): Promise<void> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user