1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-08-22 22:34:04 +02:00
bitwarden-mobile/.github/scripts/decrypt-secret.ps1
2020-06-08 13:02:38 -04:00

30 lines
738 B
PowerShell

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