Reusing extendable template
This commit is contained in:
parent
7039607cc8
commit
2989f30f3e
@ -11,85 +11,18 @@ variables:
|
|||||||
patch: $[counter(variables['prefix'], 100)]
|
patch: $[counter(variables['prefix'], 100)]
|
||||||
buildNumber: $(major).$(minor).$(patch)
|
buildNumber: $(major).$(minor).$(patch)
|
||||||
|
|
||||||
steps:
|
resources:
|
||||||
- task: PowerShell@2
|
rrepositories:
|
||||||
displayName: "Setting build version"
|
- repository: templateRepo
|
||||||
inputs:
|
endpoint: cosq-network
|
||||||
targetType: "inline"
|
type: github
|
||||||
script: |
|
name: cosq-network/azure-build-pipeline-templates
|
||||||
Write-Host "##vso[build.updatebuildnumber]$(buildNumber)"
|
|
||||||
|
|
||||||
- task: UseNode@1
|
extends:
|
||||||
displayName: "Setting up node"
|
template: template.yaml@templateRepo
|
||||||
inputs:
|
parameters:
|
||||||
version: "22"
|
nodeVersion: "20"
|
||||||
|
firebaseTokenSecret: $(FIREBASE_TOKEN)
|
||||||
- task: Bash@3
|
functionsWorkingDirectory: "$(Build.SourcesDirectory)/functions"
|
||||||
inputs:
|
envExamplePath: "$(Build.SourcesDirectory)/functions/.env.example"
|
||||||
targetType: "inline"
|
envPath: "$(Build.SourcesDirectory)/functions/.env"
|
||||||
script: |
|
|
||||||
rm -rf node_modules
|
|
||||||
npm clean-install
|
|
||||||
workingDirectory: "$(System.DefaultWorkingDirectory)/functions"
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: "Set version in package.json"
|
|
||||||
inputs:
|
|
||||||
targetType: "inline"
|
|
||||||
script: |
|
|
||||||
$pkg = Get-Content -Path "$(System.DefaultWorkingDirectory)/functions/package.json" -Raw | ConvertFrom-Json
|
|
||||||
$pkg.version = "$(buildNumber)"
|
|
||||||
$pkg | ConvertTo-Json -Depth 100 | Set-Content -Path "$(System.DefaultWorkingDirectory)/functions/package.json"
|
|
||||||
|
|
||||||
- task: CmdLine@2
|
|
||||||
displayName: "Copy .env.example to .env"
|
|
||||||
inputs:
|
|
||||||
script: |
|
|
||||||
cp "$(System.DefaultWorkingDirectory)/functions/.env.example" "$(System.DefaultWorkingDirectory)/functions/.env"
|
|
||||||
|
|
||||||
- task: replacetokens@6
|
|
||||||
displayName: "Replace tokens in .env file"
|
|
||||||
inputs:
|
|
||||||
root: "$(System.DefaultWorkingDirectory)/functions/"
|
|
||||||
sources: .env
|
|
||||||
|
|
||||||
- task: CmdLine@2
|
|
||||||
displayName: "install firebase tools"
|
|
||||||
inputs:
|
|
||||||
script: curl -sL firebase.tools | upgrade=true bash
|
|
||||||
workingDirectory: $(Agent.ToolsDirectory)
|
|
||||||
|
|
||||||
- task: Bash@3
|
|
||||||
displayName: "Deploy functions to firebase"
|
|
||||||
inputs:
|
|
||||||
targetType: "inline"
|
|
||||||
workingDirectory: "$(Build.SourcesDirectory)"
|
|
||||||
script: |
|
|
||||||
npm install -g typescript
|
|
||||||
cd functions
|
|
||||||
npm install
|
|
||||||
npx tsc
|
|
||||||
cd $(Build.SourcesDirectory)
|
|
||||||
firebase deploy --only functions --token "$(FIREBASE_TOKEN)" --force --non-interactive
|
|
||||||
|
|
||||||
- task: DeleteFiles@1
|
|
||||||
displayName: "Remove node_modules, *.log files, src directory from functions directory"
|
|
||||||
inputs:
|
|
||||||
SourceFolder: "$(System.DefaultWorkingDirectory)/functions"
|
|
||||||
Contents: |
|
|
||||||
node_modules/**
|
|
||||||
*.log
|
|
||||||
|
|
||||||
- task: ArchiveFiles@2
|
|
||||||
displayName: "Archive functions directory"
|
|
||||||
inputs:
|
|
||||||
rootFolderOrFile: "$(System.DefaultWorkingDirectory)/functions"
|
|
||||||
includeRootFolder: false
|
|
||||||
archiveFile: "$(System.DefaultWorkingDirectory)/fitlien-services-$(buildNumber).zip"
|
|
||||||
|
|
||||||
- task: CopyFiles@2
|
|
||||||
displayName: "Copy archive to staging directory"
|
|
||||||
inputs:
|
|
||||||
SourceFolder: "$(System.DefaultWorkingDirectory)"
|
|
||||||
Contents: "fitlien-services-$(buildNumber).zip"
|
|
||||||
TargetFolder: "$(System.ArtifactsDirectory)"
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user