FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
setup-java/src/cleanup-java.ts at main · stack888/setup-java · GitHub
stack888
/
setup-java
Public
forked from
actions/setup-java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
setup-java
/
src
/
cleanup-java.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (53 loc) · 1.72 KB
Breadcrumbs
setup-java
/
src
/
cleanup-java.ts
Copy path
File metadata and controls
58 lines (53 loc) · 1.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import
*
as
core
from
'@actions/core'
;
import
*
as
gpg
from
'./gpg'
;
import
*
as
constants
from
'./constants'
;
import
{
isJobStatusSuccess
}
from
'./util'
;
import
{
save
}
from
'./cache'
;
async
function
removePrivateKeyFromKeychain
(
)
{
if
(
core
.
getInput
(
constants
.
INPUT_GPG_PRIVATE_KEY
,
{
required
:
false
}
)
)
{
core
.
info
(
'Removing private key from keychain'
)
;
try
{
const
keyFingerprint
=
core
.
getState
(
constants
.
STATE_GPG_PRIVATE_KEY_FINGERPRINT
)
;
await
gpg
.
deleteKey
(
keyFingerprint
)
;
}
catch
(
error
)
{
core
.
setFailed
(
`Failed to remove private key due to:
${
error
.
message
}
`
)
;
}
}
}
/**
* Check given input and run a save process for the specified package manager
*
@returns
Promise that will be resolved when the save process finishes
*/
async
function
saveCache
(
)
{
const
jobStatus
=
isJobStatusSuccess
(
)
;
const
cache
=
core
.
getInput
(
constants
.
INPUT_CACHE
)
;
return
jobStatus
&&
cache
?
save
(
cache
)
:
Promise
.
resolve
(
)
;
}
/**
* The save process is best-effort, and it should not make the workflow fail
* even though this process throws an error.
*
@param
promise the promise to ignore error from
*
@returns
Promise that will ignore error reported by the given promise
*/
async
function
ignoreError
(
promise
:
Promise
<
void
>
)
{
return
new
Promise
(
resolve
=>
{
promise
.
catch
(
error
=>
{
core
.
warning
(
error
)
;
resolve
(
void
0
)
;
}
)
.
then
(
resolve
)
;
}
)
;
}
export
async
function
run
(
)
{
await
removePrivateKeyFromKeychain
(
)
;
await
ignoreError
(
saveCache
(
)
)
;
}
if
(
require
.
main
===
module
)
{
run
(
)
;
}
else
{
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
core
.
info
(
'the script is loaded as a module, so skipping the execution'
)
;
}
Back
|
FazBrowse Home
|
New Git URL