mirror of https://github.com/actions/toolkit
move getExpiration to upload-artifact
parent
4b219f79f3
commit
4dda3ab8a0
|
@ -1,6 +1,5 @@
|
||||||
import {getRuntimeToken} from './config'
|
import {getRuntimeToken} from './config'
|
||||||
import jwt_decode from 'jwt-decode'
|
import jwt_decode from 'jwt-decode'
|
||||||
import {Timestamp} from '../../generated'
|
|
||||||
|
|
||||||
export interface BackendIds {
|
export interface BackendIds {
|
||||||
workflowRunBackendId: string
|
workflowRunBackendId: string
|
||||||
|
@ -64,14 +63,3 @@ export function getBackendIdsFromToken(): BackendIds {
|
||||||
|
|
||||||
throw InvalidJwtError
|
throw InvalidJwtError
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getExpiration(retentionDays?: number): Timestamp | undefined {
|
|
||||||
if (!retentionDays) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
const expirationDate = new Date()
|
|
||||||
expirationDate.setDate(expirationDate.getDate() + retentionDays)
|
|
||||||
|
|
||||||
return Timestamp.fromDate(expirationDate)
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import {
|
||||||
getUploadZipSpecification,
|
getUploadZipSpecification,
|
||||||
validateRootDirectory
|
validateRootDirectory
|
||||||
} from './upload-zip-specification'
|
} from './upload-zip-specification'
|
||||||
import {getBackendIdsFromToken, getExpiration} from '../shared/util'
|
import {getBackendIdsFromToken} from '../shared/util'
|
||||||
import {CreateArtifactRequest} from 'src/generated'
|
import {CreateArtifactRequest, Timestamp} from 'src/generated'
|
||||||
|
|
||||||
export async function uploadArtifact(
|
export async function uploadArtifact(
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -91,3 +91,14 @@ export async function uploadArtifact(
|
||||||
|
|
||||||
return uploadResponse
|
return uploadResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getExpiration(retentionDays?: number): Timestamp | undefined {
|
||||||
|
if (!retentionDays) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const expirationDate = new Date()
|
||||||
|
expirationDate.setDate(expirationDate.getDate() + retentionDays)
|
||||||
|
|
||||||
|
return Timestamp.fromDate(expirationDate)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue