|
| 1 | +#Works |
| 2 | +trigger: |
| 3 | +- none |
| 4 | + |
| 5 | +pool: |
| 6 | + vmImage: ubuntu-latest |
| 7 | + |
| 8 | +stages: |
| 9 | + |
| 10 | +- stage: Build_africa |
| 11 | + displayName: Build stage africa |
| 12 | + jobs: |
| 13 | + - job: Build_africa |
| 14 | + steps: |
| 15 | + |
| 16 | + - task: DownloadSecureFile@1 |
| 17 | + displayName: 'download AFRICA backendend' |
| 18 | + inputs: |
| 19 | + secureFile: 'BACKEND_ENV_FILE_AFRICA' # string. Required. Secure File. |
| 20 | + |
| 21 | + - task: CopyFiles@2 |
| 22 | + displayName: 'copy africa backendend' |
| 23 | + inputs: |
| 24 | + SourceFolder: '$(Agent.TempDirectory)' |
| 25 | + Contents: BACKEND_ENV_FILE_AFRICA |
| 26 | + TargetFolder: './backend' |
| 27 | + |
| 28 | + - script: mv ./backend/BACKEND_ENV_FILE_AFRICA ./backend/.env |
| 29 | + displayName: 'rename africa .env' |
| 30 | + - task: DownloadSecureFile@1 |
| 31 | + displayName: 'download africa frontend' |
| 32 | + inputs: |
| 33 | + secureFile: 'FRONTEND_ENV_FILE_AFRICA' # string. Required. Secure File. |
| 34 | + |
| 35 | + - task: CopyFiles@2 |
| 36 | + displayName: 'copy africa frontend' |
| 37 | + inputs: |
| 38 | + SourceFolder: '$(Agent.TempDirectory)' |
| 39 | + Contents: FRONTEND_ENV_FILE_AFRICA |
| 40 | + TargetFolder: './frontend' |
| 41 | + |
| 42 | + - script: mv ./frontend/FRONTEND_ENV_FILE_AFRICA ./frontend/.env |
| 43 | + displayName: 'rename africa .env' |
| 44 | + |
| 45 | + - script: ls -a ./frontend |
| 46 | + displayName: 'ls' |
| 47 | + |
| 48 | + - script: ls -Rn |
| 49 | + displayName: 'ls' |
| 50 | + |
| 51 | + - task: NodeTool@0 |
| 52 | + inputs: |
| 53 | + versionSpec: '12.20.1' |
| 54 | + displayName: 'Install Node.js' |
| 55 | + |
| 56 | + - task: Bash@3 |
| 57 | + inputs: |
| 58 | + targetType: 'inline' |
| 59 | + script: | |
| 60 | + node -v |
| 61 | + npm -v |
| 62 | + npm install |
| 63 | + npm run build |
| 64 | +
|
| 65 | + - task: ArchiveFiles@2 |
| 66 | + displayName: 'Archive files' |
| 67 | + inputs: |
| 68 | + rootFolderOrFile: '$(System.DefaultWorkingDirectory)' |
| 69 | + includeRootFolder: false |
| 70 | + archiveType: zip |
| 71 | + archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip |
| 72 | + replaceExistingArchive: true |
| 73 | + - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip |
| 74 | + artifact: drop_africa |
| 75 | + |
| 76 | + - deployment: VMDeploy_AFRICA |
| 77 | + dependsOn: Build_africa |
| 78 | + displayName: DEPLOY AFRICA |
| 79 | + environment: |
| 80 | + name: PROD |
| 81 | + resourceType: VirtualMachine |
| 82 | + tags: africa |
| 83 | + strategy: |
| 84 | + runOnce: |
| 85 | + preDeploy: |
| 86 | + steps: |
| 87 | + - task: DownloadPipelineArtifact@2 |
| 88 | + inputs: |
| 89 | + buildType: 'current' |
| 90 | + artifactName: drop_africa |
| 91 | + targetPath: '$(Pipeline.Workspace)/drop_africa' |
| 92 | + |
| 93 | + - script: echo initialize, cleanup, backup, install certs |
| 94 | + |
| 95 | + deploy: |
| 96 | + steps: |
| 97 | + - task: Bash@3 |
| 98 | + inputs: |
| 99 | + targetType: 'inline' |
| 100 | + script: | |
| 101 | + # Modify deployment script based on the app type |
| 102 | + echo "Starting deployment script run" |
| 103 | + |
| 104 | +
|
| 105 | + - task: ExtractFiles@1 |
| 106 | + inputs: |
| 107 | + archiveFilePatterns: '$(Pipeline.Workspace)/drop_africa/$(Build.BuildId).zip' |
| 108 | + destinationFolder: '$(Pipeline.Workspace)/japp' |
| 109 | + cleanDestinationFolder: true |
| 110 | + overwriteExistingFiles: true |
| 111 | + |
| 112 | + - task: DeleteFiles@1 |
| 113 | + inputs: |
| 114 | + SourceFolder: '$(Pipeline.Workspace)/drop_africa' |
| 115 | + Contents: '$(Build.BuildId).zip' |
| 116 | + |
| 117 | + - task: Bash@3 |
| 118 | + inputs: |
| 119 | + targetType: 'inline' |
| 120 | + script: | |
| 121 | + cd /home/azureuser/azagent/_work/2/japp |
| 122 | + pm2 restart index |
| 123 | + sudo systemctl restart nginx |
| 124 | +
|
| 125 | + routeTraffic: |
| 126 | + steps: |
| 127 | + - script: echo routing traffic |
| 128 | + postRouteTraffic: |
| 129 | + steps: |
| 130 | + - script: echo health check post-route traffic |
| 131 | + on: |
| 132 | + failure: |
| 133 | + steps: |
| 134 | + - script: echo Restore from backup! This is on failure |
| 135 | + success: |
| 136 | + steps: |
| 137 | + - script: echo Notify! This is on success |
0 commit comments