Backup deployment scripts
This commit is contained in:
81
Deployment/build.yml
Normal file
81
Deployment/build.yml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# ASP.NET
|
||||||
|
# Build and test ASP.NET projects.
|
||||||
|
# Add steps that publish symbols, save build artifacts, deploy, and more:
|
||||||
|
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
|
||||||
|
variables:
|
||||||
|
buildConfiguration: 'Release'
|
||||||
|
targetRuntime: 'linux-x64'
|
||||||
|
selfContained: false
|
||||||
|
dotNetFramework: 'net7.0'
|
||||||
|
dotNetVersion: '7.0.x'
|
||||||
|
buildId: $(Build.BuildNumber)
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Start: Build WebAPI
|
||||||
|
- task: UseDotNet@2
|
||||||
|
inputs:
|
||||||
|
version: $(dotNetVersion)
|
||||||
|
- script: dotnet build --configuration $(buildConfiguration) "WebAPI/DiunaBI-WebAPI.csproj"
|
||||||
|
displayName: 'Build .NET 6 Application'
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: 'dotnet publish $(buildConfiguration)'
|
||||||
|
inputs:
|
||||||
|
command: publish
|
||||||
|
publishWebProjects: True
|
||||||
|
arguments: '--configuration $(BuildConfiguration) --framework $(dotNetFramework) --runtime $(targetRuntime) --self-contained $(selfContained) --output $(Build.ArtifactStagingDirectory)'
|
||||||
|
workingDirectory: 'WebAPI'
|
||||||
|
zipAfterPublish: False
|
||||||
|
- task: DeleteFiles@1
|
||||||
|
inputs:
|
||||||
|
SourceFolder: '$(Build.ArtifactStagingDirectory)/WebAPI'
|
||||||
|
Contents: |
|
||||||
|
appsettings.Development.json
|
||||||
|
client_secrets.Development.json
|
||||||
|
# End: Build WebAPI
|
||||||
|
# Start: Build Frontend
|
||||||
|
- task: NodeTool@0
|
||||||
|
inputs:
|
||||||
|
versionSpec: '18.x'
|
||||||
|
displayName: 'Install Node.js'
|
||||||
|
- script: |
|
||||||
|
npm install -g @angular/cli
|
||||||
|
npm install -g yarn
|
||||||
|
yarn install
|
||||||
|
ng config --global cli.packageManager yarn
|
||||||
|
ng build --configuration production
|
||||||
|
workingDirectory: 'Frontend'
|
||||||
|
displayName: 'npm install and build'
|
||||||
|
- task: CopyFiles@2
|
||||||
|
inputs:
|
||||||
|
SourceFolder: '$(Build.Repository.LocalPath)/Frontend/dist/diunaBI'
|
||||||
|
Contents: '**'
|
||||||
|
TargetFolder: '$(Build.ArtifactStagingDirectory)/Frontend'
|
||||||
|
- task: replacetokens@5
|
||||||
|
inputs:
|
||||||
|
rootDirectory: '$(Build.ArtifactStagingDirectory)/Frontend'
|
||||||
|
targetFiles: '**/*.js'
|
||||||
|
encoding: 'auto'
|
||||||
|
tokenPattern: 'default'
|
||||||
|
writeBOM: true
|
||||||
|
actionOnMissing: 'warn'
|
||||||
|
keepToken: true
|
||||||
|
actionOnNoFiles: 'warn'
|
||||||
|
enableTransforms: false
|
||||||
|
enableRecursion: false
|
||||||
|
useLegacyPattern: false
|
||||||
|
enableTelemetry: true
|
||||||
|
# End: Build Frontend
|
||||||
|
# Publish results
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
displayName: 'publish artifacts'
|
||||||
|
inputs:
|
||||||
|
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
|
||||||
62
Deployment/release.yml
Normal file
62
Deployment/release.yml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
Prepare config:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: qetza.replacetokens.replacetokens-task.replacetokens@5
|
||||||
|
displayName: 'Prepare config'
|
||||||
|
inputs:
|
||||||
|
rootDirectory: '$(System.DefaultWorkingDirectory)/_Duina/drop'
|
||||||
|
targetFiles: |
|
||||||
|
Frontend/main*.js
|
||||||
|
WebAPI/appsettings.json
|
||||||
|
WebAPI/client_secrets.json
|
||||||
|
verbosity: detailed
|
||||||
|
actionOnMissing: fail
|
||||||
|
actionOnNoFiles: warn
|
||||||
|
|
||||||
|
|
||||||
|
Create fronternd archive:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: ArchiveFiles@2
|
||||||
|
displayName: 'Create Frontend archive'
|
||||||
|
inputs:
|
||||||
|
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/Frontend'
|
||||||
|
archiveFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/zip/DiunaBI-Staging-Frontend.zip'
|
||||||
|
|
||||||
|
Create backend archive:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: ArchiveFiles@2
|
||||||
|
displayName: 'Create Backend archive'
|
||||||
|
inputs:
|
||||||
|
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/WebAPI'
|
||||||
|
archiveFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/zip/DiunaBI-Staging-WebAPI.zip'
|
||||||
|
|
||||||
|
Securely copy files to the remote machine:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: ArchiveFiles@2
|
||||||
|
displayName: 'Create Backend archive'
|
||||||
|
inputs:
|
||||||
|
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/WebAPI'
|
||||||
|
archiveFile: '$(System.DefaultWorkingDirectory)/_Duina/drop/zip/DiunaBI-Staging-WebAPI.zip'
|
||||||
|
|
||||||
|
Run shell commands on remote machine:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: SSH@0
|
||||||
|
displayName: 'Run shell commands on remote machine'
|
||||||
|
inputs:
|
||||||
|
sshEndpoint: 'crm.bim-it.pl'
|
||||||
|
commands: |
|
||||||
|
rm -rf /srv/diunabi.bim-it.pl/*
|
||||||
|
unzip -o /home/mz/deployment/DiunaBI-Staging-Frontend.zip -d /home/mz/deployment
|
||||||
|
bash /home/mz/deployment/updateSWHash.sh
|
||||||
|
cp -R /home/mz/deployment/Frontend/* /srv/diunabi.bim-it.pl/
|
||||||
|
sudo systemctl stop DiunaBI-WebAPI
|
||||||
|
rm -rf /home/mz/services/DiunaBI-WebAPI/*
|
||||||
|
unzip -o /home/mz/deployment/DiunaBI-Staging-WebAPI.zip -d /home/mz/deployment
|
||||||
|
cp -R /home/mz/deployment/WebAPI/* /home/mz/services/DiunaBI-WebAPI/
|
||||||
|
sudo systemctl start DiunaBI-WebAPI
|
||||||
|
rm -rf /home/mz/deployment/Frontend
|
||||||
|
rm -rf /home/mz/deployment/WebAPI
|
||||||
7
Deployment/updateSWHash.sh
Normal file
7
Deployment/updateSWHash.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
LINE=`grep -oP '.*main.*": ".*"' /home/mz/deployment/Frontend/ngsw.json`
|
||||||
|
IFS=': ' read -r -a array <<< $LINE
|
||||||
|
FILE="${array[0]//\"/}"
|
||||||
|
NEWHASH=($(sha1sum /home/mz/deployment/Frontend$FILE))
|
||||||
|
OLDHASH="${array[1]//\"/}"
|
||||||
|
sed -i "s/$OLDHASH/$NEWHASH/g" /home/mz/deployment/Frontend/ngsw.json
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"folders": [
|
|
||||||
{
|
|
||||||
"path": ".."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user