From 505ce8382f13c1f5b2a3f149a72ae4fbac272e2c Mon Sep 17 00:00:00 2001 From: wickathou Date: Mon, 6 May 2024 15:48:58 +0300 Subject: [PATCH 1/2] Updated pipeline and env files --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c54ef0134..7ddfac9d5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,16 +13,16 @@ stages: - task: DownloadSecureFile@1 displayName: 'download STAG backendend' inputs: - secureFile: 'BACKEND_ENV_FILE_STAG' # string. Required. Secure File. + secureFile: 'BACKEND_ENV_FILE_STAG_UPDATED' # string. Required. Secure File. - task: CopyFiles@2 displayName: 'copy STAG backendend' inputs: SourceFolder: '$(Agent.TempDirectory)' - Contents: BACKEND_ENV_FILE_STAG + Contents: BACKEND_ENV_FILE_STAG_UPDATED TargetFolder: './backend' - - script: mv ./backend/BACKEND_ENV_FILE_STAG ./backend/.env + - script: mv ./backend/BACKEND_ENV_FILE_STAG_UPDATED ./backend/.env displayName: 'rename STAG .env' - task: DownloadSecureFile@1 displayName: 'download STAG frontend' From 1f17529b5792b69d0d9642a2be1da1a4582f9703 Mon Sep 17 00:00:00 2001 From: wickathou Date: Mon, 6 May 2024 17:18:47 +0300 Subject: [PATCH 2/2] Added new env for prod --- azure-pipelines-eu.yml | 257 ++++++++++++++++++++--------------------- 1 file changed, 127 insertions(+), 130 deletions(-) diff --git a/azure-pipelines-eu.yml b/azure-pipelines-eu.yml index fcdda4e0f..39b12b1b5 100644 --- a/azure-pipelines-eu.yml +++ b/azure-pipelines-eu.yml @@ -1,137 +1,134 @@ # Works trigger: -- none + - none pool: - vmImage: ubuntu-latest + vmImage: ubuntu-latest stages: - -- stage: Build_europe - displayName: Build stage europe - jobs: - - job: Build_europe - steps: - - - task: DownloadSecureFile@1 - displayName: 'download EU backendend' - inputs: - secureFile: 'BACKEND_ENV_FILE_EU' # string. Required. Secure File. - - - task: CopyFiles@2 - displayName: 'copy europe backendend' - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: BACKEND_ENV_FILE_EU - TargetFolder: './backend' - - - script: mv ./backend/BACKEND_ENV_FILE_EU ./backend/.env - displayName: 'rename europe .env' - - task: DownloadSecureFile@1 - displayName: 'download europe frontend' - inputs: - secureFile: 'FRONTEND_ENV_FILE_EU' # string. Required. Secure File. - - - task: CopyFiles@2 - displayName: 'copy europe frontend' - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: FRONTEND_ENV_FILE_EU - TargetFolder: './frontend' - - - script: mv ./frontend/FRONTEND_ENV_FILE_EU ./frontend/.env - displayName: 'rename europe .env' - - - script: ls -a ./frontend - displayName: 'ls' - - - script: ls -Rn - displayName: 'ls' - - - task: NodeTool@0 - inputs: - versionSpec: '12.20.1' - displayName: 'Install Node.js' - - - task: Bash@3 - inputs: - targetType: 'inline' - script: | - node -v - npm -v - npm install - npm run build - - - task: ArchiveFiles@2 - displayName: 'Archive files' - inputs: - rootFolderOrFile: '$(System.DefaultWorkingDirectory)' - includeRootFolder: false - archiveType: zip - archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip - replaceExistingArchive: true - - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip - artifact: drop_eu - - - deployment: VMDeploy_EU - dependsOn: Build_europe - displayName: DEPLOY EU - environment: - name: PROD - resourceType: VirtualMachine - tags: europe - strategy: - runOnce: - preDeploy: - steps: - - task: DownloadPipelineArtifact@2 - inputs: - buildType: 'current' - artifactName: drop_eu - targetPath: '$(Pipeline.Workspace)/drop_eu' - - - script: echo initialize, cleanup, backup, install certs - - deploy: - steps: - - task: Bash@3 - inputs: - targetType: 'inline' - script: | - # Modify deployment script based on the app type - echo "Starting deployment script run" - - - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(Pipeline.Workspace)/drop_eu/$(Build.BuildId).zip' - destinationFolder: '$(Pipeline.Workspace)/japp' - cleanDestinationFolder: true - overwriteExistingFiles: true - - - task: DeleteFiles@1 - inputs: - SourceFolder: '$(Pipeline.Workspace)/drop_eu' - Contents: '$(Build.BuildId).zip' - - - task: Bash@3 - inputs: - targetType: 'inline' - script: | - cd /home/azureuser/azagent/_work/2/japp - pm2 restart index - sudo systemctl restart nginx - - routeTraffic: - steps: - - script: echo routing traffic - postRouteTraffic: - steps: - - script: echo health check post-route traffic - on: - failure: - steps: - - script: echo Restore from backup! This is on failure - success: + - stage: Build_europe + displayName: Build stage europe + jobs: + - job: Build_europe steps: - - script: echo Notify! This is on success \ No newline at end of file + - task: DownloadSecureFile@1 + displayName: 'download EU backendend' + inputs: + secureFile: 'BACKEND_ENV_FILE_EU_UPDATED' # string. Required. Secure File. + + - task: CopyFiles@2 + displayName: 'copy europe backendend' + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: BACKEND_ENV_FILE_EU_UPDATED + TargetFolder: './backend' + + - script: mv ./backend/BACKEND_ENV_FILE_EU_UPDATED ./backend/.env + displayName: 'rename europe .env' + - task: DownloadSecureFile@1 + displayName: 'download europe frontend' + inputs: + secureFile: 'FRONTEND_ENV_FILE_EU' # string. Required. Secure File. + + - task: CopyFiles@2 + displayName: 'copy europe frontend' + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: FRONTEND_ENV_FILE_EU + TargetFolder: './frontend' + + - script: mv ./frontend/FRONTEND_ENV_FILE_EU ./frontend/.env + displayName: 'rename europe .env' + + - script: ls -a ./frontend + displayName: 'ls' + + - script: ls -Rn + displayName: 'ls' + + - task: NodeTool@0 + inputs: + versionSpec: '12.20.1' + displayName: 'Install Node.js' + + - task: Bash@3 + inputs: + targetType: 'inline' + script: | + node -v + npm -v + npm install + npm run build + + - task: ArchiveFiles@2 + displayName: 'Archive files' + inputs: + rootFolderOrFile: '$(System.DefaultWorkingDirectory)' + includeRootFolder: false + archiveType: zip + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + replaceExistingArchive: true + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip + artifact: drop_eu + + - deployment: VMDeploy_EU + dependsOn: Build_europe + displayName: DEPLOY EU + environment: + name: PROD + resourceType: VirtualMachine + tags: europe + strategy: + runOnce: + preDeploy: + steps: + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: drop_eu + targetPath: '$(Pipeline.Workspace)/drop_eu' + + - script: echo initialize, cleanup, backup, install certs + + deploy: + steps: + - task: Bash@3 + inputs: + targetType: 'inline' + script: | + # Modify deployment script based on the app type + echo "Starting deployment script run" + + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Pipeline.Workspace)/drop_eu/$(Build.BuildId).zip' + destinationFolder: '$(Pipeline.Workspace)/japp' + cleanDestinationFolder: true + overwriteExistingFiles: true + + - task: DeleteFiles@1 + inputs: + SourceFolder: '$(Pipeline.Workspace)/drop_eu' + Contents: '$(Build.BuildId).zip' + + - task: Bash@3 + inputs: + targetType: 'inline' + script: | + cd /home/azureuser/azagent/_work/2/japp + pm2 restart index + sudo systemctl restart nginx + + routeTraffic: + steps: + - script: echo routing traffic + postRouteTraffic: + steps: + - script: echo health check post-route traffic + on: + failure: + steps: + - script: echo Restore from backup! This is on failure + success: + steps: + - script: echo Notify! This is on success