-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: Clean up workspace on deploy #835
Merged
+185
−24
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[config] | ||
command = deploy.cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off | ||
|
||
:: ---------------------- | ||
:: KUDU Deployment Script | ||
:: Version: 1.0.17 | ||
:: ---------------------- | ||
|
||
:: Prerequisites | ||
:: ------------- | ||
|
||
:: Verify node.js installed | ||
where node 2>nul >nul | ||
IF %ERRORLEVEL% NEQ 0 ( | ||
echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment. | ||
goto error | ||
) | ||
|
||
:: Setup | ||
:: ----- | ||
|
||
setlocal enabledelayedexpansion | ||
|
||
SET ARTIFACTS=%~dp0%..\artifacts | ||
|
||
IF NOT DEFINED DEPLOYMENT_SOURCE ( | ||
SET DEPLOYMENT_SOURCE=%~dp0%. | ||
) | ||
|
||
IF NOT DEFINED DEPLOYMENT_TARGET ( | ||
SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot | ||
) | ||
|
||
IF NOT DEFINED NEXT_MANIFEST_PATH ( | ||
SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest | ||
|
||
IF NOT DEFINED PREVIOUS_MANIFEST_PATH ( | ||
SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest | ||
) | ||
) | ||
|
||
IF NOT DEFINED KUDU_SYNC_CMD ( | ||
:: Install kudu sync | ||
echo Installing Kudu Sync | ||
call npm install kudusync -g --silent | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
|
||
:: Locally just running "kuduSync" would also work | ||
SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd | ||
) | ||
goto Deployment | ||
|
||
:: Utility Functions | ||
:: ----------------- | ||
|
||
:SelectNodeVersion | ||
|
||
IF DEFINED KUDU_SELECT_NODE_VERSION_CMD ( | ||
:: The following are done only on Windows Azure Websites environment | ||
call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
|
||
IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" ( | ||
SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
) | ||
|
||
IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" ( | ||
SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
) | ||
|
||
IF NOT DEFINED NODE_EXE ( | ||
SET NODE_EXE=node | ||
) | ||
|
||
SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!" | ||
) ELSE ( | ||
SET NPM_CMD=npm | ||
SET NODE_EXE=node | ||
) | ||
|
||
goto :EOF | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
:: Deployment | ||
:: ---------- | ||
|
||
:Deployment | ||
echo Handling node.js deployment. | ||
|
||
:: 1. KuduSync | ||
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" ( | ||
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
) | ||
|
||
:: 2. Select node version | ||
call :SelectNodeVersion | ||
|
||
:: 3. Clean up previous deployments | ||
IF EXIST "%DEPLOYMENT_TARGET%\node_modules\" ( | ||
pushd "%DEPLOYMENT_TARGET%" | ||
call :ExecuteCmd RD /S /Q "node_modules" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
popd | ||
) | ||
|
||
IF EXIST "%DEPLOYMENT_TARGET%\package-lock.json" ( | ||
pushd "%DEPLOYMENT_TARGET%" | ||
call :ExecuteCmd DEL "package-lock.json" | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
popd | ||
) | ||
|
||
|
||
:: 4. Install npm packages | ||
IF EXIST "%DEPLOYMENT_TARGET%\package.json" ( | ||
pushd "%DEPLOYMENT_TARGET%" | ||
call :ExecuteCmd !NPM_CMD! install --production | ||
IF !ERRORLEVEL! NEQ 0 goto error | ||
popd | ||
) | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
goto end | ||
|
||
:: Execute command routine that will echo out when error | ||
:ExecuteCmd | ||
setlocal | ||
set _CMD_=%* | ||
call %_CMD_% | ||
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_% | ||
exit /b %ERRORLEVEL% | ||
|
||
:error | ||
endlocal | ||
echo An error has occurred during web site deployment. | ||
call :exitSetErrorLevel | ||
call :exitFromFunction 2>nul | ||
|
||
:exitSetErrorLevel | ||
exit /b 1 | ||
|
||
:exitFromFunction | ||
() | ||
|
||
:end | ||
endlocal | ||
echo Finished successfully. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to install
hint
somewhere to test staging or we could usenpx hint https://staging