Skip to content
Merged
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-asia.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_asia
displayName: Build stage asia
jobs:
- job: Build_asia
steps:

- task: DownloadSecureFile@1
displayName: 'download ASIA backendend'
inputs:
secureFile: 'BACKEND_ENV_FILE_ASIA' # string. Required. Secure File.

- task: CopyFiles@2
displayName: 'copy asia backendend'
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: BACKEND_ENV_FILE_ASIA
TargetFolder: './backend'

- script: mv ./backend/BACKEND_ENV_FILE_ASIA ./backend/.env
displayName: 'rename asia .env'
- task: DownloadSecureFile@1
displayName: 'download asia frontend'
inputs:
secureFile: 'FRONTEND_ENV_FILE_ASIA' # string. Required. Secure File.

- task: CopyFiles@2
displayName: 'copy asia frontend'
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: FRONTEND_ENV_FILE_ASIA
TargetFolder: './frontend'

- script: mv ./frontend/FRONTEND_ENV_FILE_ASIA ./frontend/.env
displayName: 'rename asia .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_asia

- deployment: VMDeploy_ASIA
dependsOn: Build_asia
displayName: DEPLOY ASIA
environment:
name: PROD
resourceType: VirtualMachine
tags: asia
strategy:
runOnce:
preDeploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: drop_asia
targetPath: '$(Pipeline.Workspace)/drop'

- 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_asia/$(Build.BuildId).zip'
destinationFolder: '$(Pipeline.Workspace)/japp'
cleanDestinationFolder: true
overwriteExistingFiles: true

- task: DeleteFiles@1
inputs:
SourceFolder: '$(Pipeline.Workspace)/drop_asia'
Contents: '$(Build.BuildId).zip'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
cd /home/azureuser/azagent/_work/1/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_asia
displayName: Build stage asia
jobs:
- job: Build_asia
steps:
- script: echo Notify! This is on success
- task: DownloadSecureFile@1
displayName: 'download ASIA backendend'
inputs:
secureFile: 'BACKEND_ENV_FILE_ASIA_REV2' # string. Required. Secure File.

- task: CopyFiles@2
displayName: 'copy asia backendend'
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: BACKEND_ENV_FILE_ASIA_REV2
TargetFolder: './backend'

- script: mv ./backend/BACKEND_ENV_FILE_ASIA_REV2 ./backend/.env
displayName: 'rename asia .env'
- task: DownloadSecureFile@1
displayName: 'download asia frontend'
inputs:
secureFile: 'FRONTEND_ENV_FILE_ASIA_REV2' # string. Required. Secure File.

- task: CopyFiles@2
displayName: 'copy asia frontend'
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: FRONTEND_ENV_FILE_ASIA_REV2
TargetFolder: './frontend'

- script: mv ./frontend/FRONTEND_ENV_FILE_ASIA_REV2 ./frontend/.env
displayName: 'rename asia .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_asia

- deployment: VMDeploy_ASIA
dependsOn: Build_asia
displayName: DEPLOY ASIA
environment:
name: PROD
resourceType: VirtualMachine
tags: asia
strategy:
runOnce:
preDeploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: drop_asia
targetPath: '$(Pipeline.Workspace)/drop_asia'

- 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_asia/$(Build.BuildId).zip'
destinationFolder: '$(Pipeline.Workspace)/japp'
cleanDestinationFolder: true
overwriteExistingFiles: true

- task: DeleteFiles@1
inputs:
SourceFolder: '$(Pipeline.Workspace)/drop_asia'
Contents: '$(Build.BuildId).zip'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
cd /home/azureuser/azagent/_work/1/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