Skip to content

Commit

Permalink
better log output
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-smith committed Jun 21, 2022
1 parent 7b0087c commit bcf81ac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ private static string GenerateWorkflow(string targetOrg, string targetRepo, stri
build:
runs-on: windows-latest
steps:
- run: |
- name: Install Crypto Package
run: |
Install-Package -Name Sodium.Core -ProviderName NuGet -Scope CurrentUser -RequiredVersion 1.3.0 -Destination . -Force
shell: pwsh
- name: Migrate Secrets
run: |
$sodiumPath = Resolve-Path "".\Sodium.Core.1.3.0\lib\\netstandard2.1\Sodium.Core.dll""
[System.Reflection.Assembly]::LoadFrom($sodiumPath)
Expand All @@ -112,6 +116,7 @@ private static string GenerateWorkflow(string targetOrg, string targetRepo, stri
$secretValue = $secrets.""$secretName""
if ($secretName -ne ""github_token"" -and $secretName -ne ""SECRETS_MIGRATOR_PAT"") {{
Write-Output ""Migrating Secret: $secretName""
$secretBytes = [Text.Encoding]::UTF8.GetBytes($secretValue)
$sealedPublicKeyBox = [Sodium.SealedPublicKeyBox]::Create($secretBytes, $publicKey)
$encryptedSecret = [Convert]::ToBase64String($sealedPublicKeyBox)
Expand All @@ -129,6 +134,7 @@ private static string GenerateWorkflow(string targetOrg, string targetRepo, stri
}}
}}
Write-Output ""Cleaning up...""
Invoke-RestMethod -Uri ""https://api.github.com/repos/${{{{ github.repository }}}}/git/${{{{ github.ref }}}}"" -Method ""DELETE"" -Headers @{{ Authorization = ""Basic $targetPat"" }}
Invoke-RestMethod -Uri ""https://api.github.com/repos/${{{{ github.repository }}}}/actions/secrets/SECRETS_MIGRATOR_PAT"" -Method ""DELETE"" -Headers @{{ Authorization = ""Basic $targetPat"" }}
env:
Expand Down

0 comments on commit bcf81ac

Please sign in to comment.