2020-06-08 18:14:10 +02:00
|
|
|
|
param (
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
|
[string] $filename,
|
|
|
|
|
[string] $output
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$homePath = $env:HOME
|
|
|
|
|
$rootPath = $env:GITHUB_WORKSPACE
|
|
|
|
|
|
2020-06-08 19:00:52 +02:00
|
|
|
|
$secretInputPath = $rootPath + "\.github\secrets"
|
|
|
|
|
$input = $secretInputPath + "\" + $filename
|
2020-06-08 18:14:10 +02:00
|
|
|
|
|
|
|
|
|
$passphrase = $env:DECRYPT_FILE_PASSWORD
|
2020-06-08 19:00:52 +02:00
|
|
|
|
$secretOutputPath = $homePath + "\secrets"
|
2020-06-08 18:14:10 +02:00
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($output)) {
|
2020-06-08 19:19:44 +02:00
|
|
|
|
if ($filename.EndsWith(".gpg")) {
|
2020-06-08 19:00:52 +02:00
|
|
|
|
$output = $secretOutputPath + "\" + $filename.TrimEnd(".gpg")
|
2020-06-08 18:14:10 +02:00
|
|
|
|
} else {
|
2020-06-08 19:00:52 +02:00
|
|
|
|
$output = $secretOutputPath + "\" + $filename + ".plaintext"
|
2020-06-08 18:14:10 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 19:19:44 +02:00
|
|
|
|
if (!(Test-Path -Path $secretOutputPath))
|
2020-06-08 18:14:10 +02:00
|
|
|
|
{
|
2020-06-08 19:02:38 +02:00
|
|
|
|
New-Item -ItemType Directory -Path $secretOutputPath
|
2020-06-08 18:14:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpg --quiet --batch --yes --decrypt --passphrase="$passphrase" --output $output $input
|