1 changed files with 36 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
# powershell 脚本,等待输入ID |
||||
|
$Type = Read-Host "input deploy type(api/web):" |
||||
|
# 如果输入不是api或者web,则退出 |
||||
|
if ($Type -ne "api" -and $Type -ne "web") { |
||||
|
Write-Host "error, input must be api or web" |
||||
|
exit |
||||
|
} |
||||
|
|
||||
|
# 获取文件夹下所有文件的文件名,不包括扩展名,赋值给变量 |
||||
|
$files = Get-ChildItem '.\etc\*.yaml' | ForEach-Object { $_.BaseName } |
||||
|
|
||||
|
# 获取Dockerfile |
||||
|
Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/Dockerfile -o Dockerfile |
||||
|
# 使用文件名替换Dockerfile中的Name-For-Replace |
||||
|
$files | ForEach-Object { (Get-Content 'Dockerfile') -replace 'Name-For-Replace', $_ | Set-Content 'Dockerfile' } |
||||
|
|
||||
|
# 获取k8s.yaml |
||||
|
Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/k8s.yaml -o k8s.yaml |
||||
|
# 使用文件名替换k8s.yaml中的Name-For-Replace |
||||
|
$files | ForEach-Object { (Get-Content 'k8s.yaml') -replace 'Name-For-Replace', $_ | Set-Content 'k8s.yaml' } |
||||
|
|
||||
|
# 使用$type替换k8s.yaml中的Type-For-Replace |
||||
|
(Get-Content 'k8s.yaml') -replace 'Type-For-Replace', $Type | Set-Content 'k8s.yaml' |
||||
|
|
||||
|
|
||||
|
# 获取replaceTag.ps1,不做改动 |
||||
|
Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/replaceTag.ps1 -o replaceTag.ps1 |
||||
|
|
||||
|
# 获取swagger.bat, |
||||
|
Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/swagger.bat -o swagger.bat |
||||
|
# $files去除字符串中的-,赋值给变量 |
||||
|
$filesjson = $files -replace '-', '' |
||||
|
# 再去除字符串最后的api或者web |
||||
|
$filesjson = $filesjson -replace 'api', '' |
||||
|
# 使用新文件名替换swagger.bat中的Name-For-Replace |
||||
|
$filesjson | ForEach-Object { (Get-Content 'swagger.bat') -replace 'Name-For-Replace', $_ | Set-Content 'swagger.bat' } |
Loading…
Reference in new issue