-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathstarter-template-publisher.yml
96 lines (87 loc) · 4.98 KB
/
starter-template-publisher.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
# trigger:
# - main
pool:
vmImage: ubuntu-latest
steps:
- script: echo ProjectTemplate Process Starting...
# displayName: 'Run a one-line script'
- task: PowerShell@2
displayName: Getting directory structure ready
inputs:
targetType: 'inline'
script: |
Write-Host "Renaming frontend to adminportal and delete Intent"
Rename-Item -Path "frontend" -NewName "adminportal"
# Remove-Item -LiteralPath "intent/.intent" -Force -Recurse
Write-Host "Completed"
Write-Host "Copy database to root and delete database folder"
Copy-Item 'database/*' -Destination '.' -Recurse
Remove-Item -LiteralPath "database" -Force -Recurse
Write-Host "Completed"
# Write-Host "Changing version reference in packages.json to latest public version"
# Set-Location -Path "$(System.DefaultWorkingDirectory)/shesha-starter/adminportal"
# $filePath = "package.json"
# $Jsonfile = Get-Content $filePath -raw | ConvertFrom-Json
# $Jsonfile.dependencies.'@shesha-io/reactjs' = "latest"
# ConvertTo-Json $Jsonfile -Depth 5 | Set-Content $filePath
Write-Host "Completed"
workingDirectory: '$(System.DefaultWorkingDirectory)/shesha-starter/'
- task: ArchiveFiles@2
displayName: Zip Starter Directory
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/shesha-starter/'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
# - task: 7z@1
# displayName: Zip Starter Directory
# inputs:
# Folder: '$(System.DefaultWorkingDirectory)/shesha-starter/'
# Archive: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
# ArchiveFormat: 'zip'
# - task: Bash@3
# displayName: Curl Starter zip file to DemoShesha
# inputs:
# targetType: 'inline'
# script: |
# echo 'Starting'
# curl -X 'POST' \
# 'https://demoshesha.azurewebsites.net/api/services/SheshaAspnetCoreDemo/ProjectTemplate/Create' \
# -H 'accept: application/json' \
# -H 'Content-Type: multipart/form-data' \
# -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6IjM3NzZiODQyLTc1NmUtN2YzZi00YmNlLTM5ZjBlNmFlYThhOSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6IjU2ZTQ1ZDJmLTA0YWItNDVkMS04ZmY3LTgzMTliZTRlNGNhOCIsImlhdCI6MTcwNjgxOTg5NSwibmJmIjoxNzA2ODE5ODk1LCJleHAiOjE3MDcyNTE4OTUsImlzcyI6IlNoZXNoYSIsImF1ZCI6IlNoZXNoYSJ9.UMHjyEVfnl2hwkb2dsOjD5DWso5YFd4_EzQsW8qrtOc' \
# -F 'zipFile=@$(Build.BuildId).zip;type=application/x-zip-compressed' \
# -F 'name=shesha-starter-template-@$(Build.BuildId)' \
# -F 'description=A shesha starter template using the pipeline' \
# -F 'version=$(Build.SourceBranch)' \
# -F 'isPublished=true'
# echo 'Completed'
# Obtain the token
# response=$(curl -X POST "https://demoshesha.azurewebsites.net/swagger/index.html" \
# -H "Content-Type: application/x-www-form-urlencoded" \
# -d "grant_type=client_credentials&client_id=admin&client_secret=123qwe")
# token=$(echo $response | jq -r '.access_token')
# Use the token in the API request
- task: Bash@3
displayName: Curl Starter zip file to DemoShesha
inputs:
targetType: 'inline'
script: |
echo 'Starting'
curl -X 'POST' \
'https://demoshesha.azurewebsites.net/api/services/SheshaAspnetCoreDemo/ProjectTemplate/Create' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6IjM3NzZiODQyLTc1NmUtN2YzZi00YmNlLTM5ZjBlNmFlYThhOSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6ImRhNTllNjc3LTJiYjgtNGY3ZS04ZjZmLWJjMmZhZGY4NzJkZCIsImlhdCI6MTcyNDEyOTczMywibmJmIjoxNzI0MTI5NzMzLCJleHAiOjE3MjQ1NjE3MzMsImlzcyI6IlNoZXNoYSIsImF1ZCI6IlNoZXNoYSJ9.zPGW5pO1FYL9peB2zjvGnIvMFvEx7vJzvlSW5SaLHP8' \
-F 'zipFile=@$(Build.BuildId).zip;type=application/x-zip-compressed' \
-F 'name=shesha-starter-template-@$(Build.BuildId)' \
-F 'description=A shesha starter template using the pipeline' \
-F 'version=$(Build.SourceBranch)' \
-F 'isPublished=true'
echo 'Completed'
workingDirectory: '$(Build.ArtifactStagingDirectory)'