Skip to content

Instantly share code, notes, and snippets.

@matejskubic
Created June 3, 2024 19:11
Show Gist options
  • Save matejskubic/25c7fdfb0da857602b7e7e58215252ec to your computer and use it in GitHub Desktop.
Save matejskubic/25c7fdfb0da857602b7e7e58215252ec to your computer and use it in GitHub Desktop.
Copy GitHub action variables
# Export to .env file - Does not work with Windows Poershell 5.1
$tmpFile = [System.IO.Path]::GetTempFileName()
Write-Verbose -Verbose "Using $tmpFile"
gh variable list --json name,value --template "{{range .}}{{.name}}={{.value}}`n{{end}}" | Out-File -FilePath $tmpFile -Encoding utf8NoBOM
# cd to new repo or update Owner/Repo
gh variable set --env-file $tmpFile --repo Owner/Repo
Remove-Item $tmpFile
$ghVars = gh variable list --json name,value | ConvertFrom-Json
# cd to new repo or update Owner/Repo
gh variable set --env-file $tmpFile --repo Owner/Repo
$ghVars | % { $_.value | gh variable set $_.name --repo Owner/Repo }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment