From a813c42d33b3634359a03e8084e9282ae31c17dd Mon Sep 17 00:00:00 2001 From: "Ethan N. Paul" Date: Mon, 29 Jan 2018 09:33:52 -0500 Subject: [PATCH] Updated ci config to support both iis and apache release and dev --- .ci-dev.ps1 | 29 +++++++++++++++++++ .ci-release.ps1 | 29 +++++++++++++++++++ .gitlab-ci.yml | 77 ++++++++++++++++++++++++++++++++++++------------- deploy.ps1 | 29 ------------------- 4 files changed, 115 insertions(+), 49 deletions(-) create mode 100644 .ci-dev.ps1 create mode 100644 .ci-release.ps1 delete mode 100644 deploy.ps1 diff --git a/.ci-dev.ps1 b/.ci-dev.ps1 new file mode 100644 index 0000000..baa9ca3 --- /dev/null +++ b/.ci-dev.ps1 @@ -0,0 +1,29 @@ +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev" -Recurse -Force +} + +New-Item -Path "C:\inetpub\wwwroot\" -Name "build-tmp.enpaul-dev" -ItemType Directory -Force + +Copy-Item -Path ".\*" -Destination "C:\inetpub\wwwroot\build-tmp.enpaul-dev\" -Force -Recurse + +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.git") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.git" -Recurse -Force +} +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.gitlab-ci.yml") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.gitlab-ci.yml" -Force +} +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\deploy.ps1") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\deploy.ps1" -Force +} +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.gitignore") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.gitignore" -Force +} +if (Test-Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.htaccess") { + Remove-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev\.htaccess" -Force +} + +Rename-Item -Path "C:\inetpub\wwwroot\enpaul-dev" -NewName "enpaul-dev.old" -Force +Rename-Item -Path "C:\inetpub\wwwroot\build-tmp.enpaul-dev" -NewName "enpaul-dev" -Force + +Remove-Item -path "C:\inetpub\wwwroot\enpaul-dev.old" -Recurse -Force +exit diff --git a/.ci-release.ps1 b/.ci-release.ps1 new file mode 100644 index 0000000..3cc2816 --- /dev/null +++ b/.ci-release.ps1 @@ -0,0 +1,29 @@ +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul" -Recurse -Force +} + +New-Item -Path "C:\inetpub\wwwroot\" -Name "tmp-build.enpaul" -ItemType Directory -Force + +Copy-Item -Path ".\*" -Destination "C:\inetpub\wwwroot\tmp-build.enpaul\" -Force -Recurse + +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul\.git") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul\.git" -Recurse -Force +} +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul\.gitlab-ci.yml") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul\.gitlab-ci.yml" -Force +} +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul\deploy.ps1") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul\deploy.ps1" -Force +} +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul\.gitignore") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul\.gitignore" -Force +} +if (Test-Path "C:\inetpub\wwwroot\tmp-build.enpaul\.htaccess") { + Remove-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul\.htaccess" -Force +} + +Rename-Item -Path "C:\inetpub\wwwroot\enpaul" -NewName "enpaul.old" -Force +Rename-Item -Path "C:\inetpub\wwwroot\tmp-build.enpaul" -NewName "enpaul" -Force + +Remove-Item -path "C:\inetpub\wwwroot\enpaul.old" -Recurse -Force +exit diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94fa171..5deb01f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,61 @@ stages: - - deploy-apache + - deploy-release-apache + - deploy-dev-apache + - deploy-release-iis + - deploy-dev-iis -#IIS Deployment: -# stage: deploy-iis -# script: -# - powershell .\deploy.ps1 -# tags: -# - iis - -Apache Deployment: - stage: deploy-apache +IIS Production: + stage: deploy-release-iis script: - - mkdir /var/www/html/enpaul.new - - rm ./deploy.ps1 - - rm ./web.config - - rm ./.gitlab-ci.yml - - cp -r ./* /var/www/html/enpaul.new/ - - cp ./.htaccess /var/www/html/enpaul.new/ - - mv /var/www/html/enpaul /var/www/html/enpaul.old - - mv /var/www/html/enpaul.new /var/www/html/enpaul - - rm -r /var/www/html/enpaul.old + - powershell .\.ci-release.ps1 + only: + - master tags: - - apache + - release-iis + +IIS Development: + stage: deploy-dev-iis + script: + - powershell .\.ci-dev.ps1 + only: + - development + tags: + - dev-iis + +Apache Production: + stage: deploy-release-apache + script: + - [ -d /var/www/html/build-tmp.enpaul ] && rm -r /var/www/html/build-tmp.enpaul + - mkdir /var/www/html/build-tmp.enpaul + - cp -r ./* /var/www/html/build-tmp.enpaul/ + - rm /var/www/html/build-tmp.enpaul/.ci-release.ps1 + - rm /var/www/html/build-tmp.enpaul/.ci-dev.ps1 + - rm /var/www/html/build-tmp.enpaul/web.config + - rm /var/www/html/build-tmp.enpaul/.gitlab-ci.yml + - rm -r /var/www/html/build-tmp.enpaul/.git + - [ -d /var/www/html/enpaul ] && mv /var/www/html/enpaul /var/www/html/enpaul.old + - mv /var/www/html/build-tmp.enpaul /var/www/html/enpaul + - rm -r /var/www/html/enpaul.old + only: + - master + tags: + - release-apache + + Apache Development: + stage: deploy-dev-apache + script: + - [ -d /var/www/html/build-tmp.enpaul-dev ] && rm -r /var/www/html/build-tmp.enpaul-dev + - mkdir /var/www/html/build-tmp.enpaul-dev + - cp -r ./* /var/www/html/build-tmp.enpaul-dev/ + - rm /var/www/html/build-tmp.enpaul-dev/.ci-release.ps1 + - rm /var/www/html/build-tmp.enpaul-dev/.ci-dev.ps1 + - rm /var/www/html/build-tmp.enpaul-dev/web.config + - rm /var/www/html/build-tmp.enpaul-dev/.gitlab-ci.yml + - rm -r /var/www/html/build-tmp.enpaul-dev/.git + - [ -d /var/www/html/enpaul-dev ] && mv /var/www/html/enpaul-dev /var/www/html/enpaul-dev.old + - mv /var/www/html/build-tmp.enpaul-dev /var/www/html/enpaul-dev + - rm -r /var/www/html/enpaul-dev.old + only: + - development + tags: + - dev-apache diff --git a/deploy.ps1 b/deploy.ps1 deleted file mode 100644 index ca73d01..0000000 --- a/deploy.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new" -Recurse -Force -} - -New-Item -Path "C:\inetpub\wwwroot\" -Name "enpaul.net.new" -ItemType Directory -Force - -Copy-Item -Path ".\*" -Destination "C:\inetpub\wwwroot\enpaul.net.new\" -Force -Recurse - -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new\.git") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new\.git" -Recurse -Force -} -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new\.gitlab-ci.yml") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new\.gitlab-ci.yml" -Force -} -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new\deploy.ps1") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new\deploy.ps1" -Force -} -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new\.gitignore") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new\.gitignore" -Force -} -if (Test-Path "C:\inetpub\wwwroot\enpaul.net.new\.htaccess") { - Remove-Item -Path "C:\inetpub\wwwroot\enpaul.net.new\.htaccess" -Force -} - -Rename-Item -Path "C:\inetpub\wwwroot\enpaul.net" -NewName "enpaul.net.old" -Force -Rename-Item -Path "C:\inetpub\wwwroot\enpaul.net.new" -NewName "enpaul.net" -Force - -Remove-Item -path "C:\inetpub\wwwroot\enpaul.net.old" -Recurse -Force -exit