mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-04-05 04:44:16 +02:00
Add feature to set artifact retention period
Signed-off-by: Duncan Casteleyn <10881109+DuncanCasteleyn@users.noreply.github.com>
This commit is contained in:
parent
0bfe00a136
commit
100a4be158
3 changed files with 50 additions and 2 deletions
29
README.md
29
README.md
|
@ -796,6 +796,35 @@ jobs:
|
||||||
|
|
||||||
The `retry-on-snapshot-warnings-timeout` (in seconds) needs to be long enough to allow the entire `run-build-and-generate-dependency-snapshot` and `submit-dependency-snapshot` workflows (above) to complete.
|
The `retry-on-snapshot-warnings-timeout` (in seconds) needs to be long enough to allow the entire `run-build-and-generate-dependency-snapshot` and `submit-dependency-snapshot` workflows (above) to complete.
|
||||||
|
|
||||||
|
### Artifact retention
|
||||||
|
|
||||||
|
By default, GitHub retains artifacts for 90 days
|
||||||
|
|
||||||
|
If desired, it is possible to override the retention period of the artifacts by specifying the retention-days input.
|
||||||
|
The input should be a number between 0 and 90, 0 is interpreted as default.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Submit dependency graph
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup Gradle to generate and submit dependency graphs
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
with:
|
||||||
|
dependency-graph: generate-and-submit
|
||||||
|
retention-days: 1
|
||||||
|
- name: Run a build and generate the dependency graph which will be submitted post-job
|
||||||
|
run: ./gradlew build
|
||||||
|
```
|
||||||
|
|
||||||
## Gradle version compatibility
|
## Gradle version compatibility
|
||||||
|
|
||||||
The GitHub Dependency Graph plugin should be compatible with all versions of Gradle >= 5.0, and has been tested against
|
The GitHub Dependency Graph plugin should be compatible with all versions of Gradle >= 5.0, and has been tested against
|
||||||
|
|
|
@ -11,7 +11,8 @@ import * as path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
import * as layout from './repository-layout'
|
import * as layout from './repository-layout'
|
||||||
import {DependencyGraphOption, getJobMatrix} from './input-params'
|
import {DependencyGraphOption, getJobMatrix, getRetentionDays} from './input-params'
|
||||||
|
import {UploadOptions} from "@actions/artifact";
|
||||||
|
|
||||||
const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'
|
const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'
|
||||||
|
|
||||||
|
@ -60,7 +61,12 @@ async function uploadDependencyGraphs(): Promise<string[]> {
|
||||||
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`)
|
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`)
|
||||||
|
|
||||||
const artifactClient = artifact.create()
|
const artifactClient = artifact.create()
|
||||||
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory)
|
|
||||||
|
const options: UploadOptions = {
|
||||||
|
retentionDays: getRetentionDays()
|
||||||
|
}
|
||||||
|
|
||||||
|
await artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory, options)
|
||||||
|
|
||||||
return graphFiles
|
return graphFiles
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,19 @@ export function getDependencyGraphOption(): DependencyGraphOption {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRetentionDays(): number | undefined {
|
||||||
|
const val = core.getInput('retention-days')
|
||||||
|
if (val) {
|
||||||
|
const retentionDays = parseInt(val)
|
||||||
|
if (isNaN(retentionDays) || retentionDays < 0 || retentionDays > 90) {
|
||||||
|
throw TypeError(`The value ${val} is not valid for retention-days. Valid values are numbers between 0 and 90`)
|
||||||
|
}
|
||||||
|
return retentionDays
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function getBooleanInput(paramName: string, paramDefault = false): boolean {
|
function getBooleanInput(paramName: string, paramDefault = false): boolean {
|
||||||
const paramValue = core.getInput(paramName)
|
const paramValue = core.getInput(paramName)
|
||||||
switch (paramValue.toLowerCase().trim()) {
|
switch (paramValue.toLowerCase().trim()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue