Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 127 additions & 130 deletions azure-pipelines-eu.yml
Original file line number Diff line number Diff line change
@@ -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
- 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
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down