Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(ci): Add azure build pipeline #3523

Draft
wants to merge 7 commits into
base: vnext
Choose a base branch
from
Draft
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
130 changes: 130 additions & 0 deletions azure-pipelines/azure-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
trigger:
branches:
include:
- master
- vnext

# This pipeline is meant to build specific branches for deployment. It's not meant to be a part of PR validation. Ensure that this pipeline is reserved for deployment purposes.
pr: none

name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

variables:
githubToken: <value> # Add a GitHub token in Libraries
ReplacementText: '@infragistics/igniteui-angular-extras'

jobs:
- job: CommonSteps
displayName: Common Steps for All Jobs
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
clean: true
fetchTags: true

- task: NodeTool@0
displayName: Use Node 20.x
inputs:
versionSpec: 20.x

- task: Npm@1
displayName: npm cache clean
continueOnError: true
inputs:
command: custom
workingDir: $(Build.SourcesDirectory)
verbose: false
customCommand: cache clean --force

- task: Npm@1
displayName: npm cache verify
inputs:
command: custom
workingDir: $(Build.SourcesDirectory)
verbose: false
customCommand: cache verify

- task: RegexReplace@3
displayName: RegEx Find & Replace
inputs:
InputSearchPattern: |
projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.module.ts
projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts
projects/app-lob/src/app/app.module.ts
package.json
FindRegex: igniteui-angular-extras
ReplaceRegex: $(ReplacementText)
UseUTF8: false

- task: Npm@1
displayName: npm install
inputs:
workingDir: $(Build.SourcesDirectory)
verbose: false

- task: CmdLine@2
displayName: Clone submodule
inputs:
script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples
workingDirectory: ${{ parameters.workingDir }}

- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.SourcesDirectory)'
artifact: 'source-code'
publishLocation: 'pipeline'

- job: Job_1
displayName: App CD Build
dependsOn: CommonSteps
pool:
vmImage: ubuntu-latest
steps:
- download: current
artifact: source-code
- template: template.yml
parameters:
customCommand: run generate-live-editing
workingDir: $(Build.SourcesDirectory)
submoduleDir: angular-demos
baseHref: /angular-demos/
targetFolder: dist/app-lob
findRegex: angular-demos
npmBuildCommand: 'run build-ci'

- job: Job_2
displayName: App CRM Build
dependsOn: CommonSteps
pool:
vmImage: ubuntu-latest
steps:
- download: current
artifact: source-code
- template: template.yml
parameters:
customCommand: run generate-live-editing:app-crm
workingDir: $(Build.SourcesDirectory)
submoduleDir: angular-demos-crm
baseHref: /angular-demos-grid-crm/
targetFolder: dist/app-crm
findRegex: angular-demos
npmBuildCommand: 'run build-ci:app-crm --loglevel verbose'

- job: Job_3
displayName: App LOB Build
dependsOn: CommonSteps
pool:
vmImage: ubuntu-latest
steps:
- download: current
artifact: source-code
- template: template.yml
parameters:
customCommand: run generate-live-editing:app-lob
workingDir: $(Build.SourcesDirectory)
submoduleDir: angular-demos-lob
baseHref: /angular-demos-lob/
targetFolder: dist/app-lob
findRegex: angular-demos
npmBuildCommand: 'run build-ci:app-lob'
144 changes: 144 additions & 0 deletions azure-pipelines/templates/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# template.yml
parameters:
- name: customCommand
type: string
- name: workingDir
type: string
- name: submoduleDir
type: string
- name: baseHref
type: string
- name: targetFolder
type: string
default: 'dist'
- name: findRegex
type: string
- name: npmBuildCommand
type: string
default: ''
- name: runCleanup
type: boolean
default: true

steps:
# - task: CmdLine@2
# displayName: Clone submodule
# inputs:
# script: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples
# workingDirectory: ${{ parameters.workingDir }}

- task: CmdLine@2
displayName: Staging - Git checkout branch
condition: eq(variables['Build.SourceBranchName'], 'vNext')
inputs:
script: git checkout vNext
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples

- task: CmdLine@2
displayName: Production - Git checkout branch
condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI'))
inputs:
script: git checkout master
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples

- script: |
sed -i 's/--configuration production/--base-href=${{ parameters.baseHref }} --configuration production/g' package.json
displayName: 'Update package.json file'
workingDirectory: ${{ parameters.workingDir }}

- task: Npm@1
displayName: generate live-editing
inputs:
command: custom
workingDir: ${{ parameters.workingDir }}
verbose: false
customCommand: ${{ parameters.customCommand }}

- task: CmdLine@2
displayName: Update to licensed igniteui-angular
inputs:
script: npx ng g @igniteui/angular-schematics:upgrade-packages --skip-install
workingDirectory: ${{ parameters.workingDir }}

- task: Npm@1
displayName: ${{ parameters.npmBuildCommand }}
inputs:
command: custom
workingDir: ${{ parameters.workingDir }}
verbose: false
customCommand: ${{ parameters.npmBuildCommand }}

- task: CopyFiles@2
displayName: Copy web.config
inputs:
SourceFolder: $(Build.SourcesDirectory)
Contents: web.config
TargetFolder: $(Build.SourcesDirectory)/${{ parameters.targetFolder }}

- task: RegexReplace@3
displayName: RegEx Find & Replace
inputs:
InputSearchPattern: $(Build.SourcesDirectory)/${{ parameters.targetFolder }}/web.config
FindRegex: ${{ parameters.findRegex }}
ReplaceRegex: ${{ parameters.submoduleDir }}
UseUTF8: false

- task: PublishPipelineArtifact@1
displayName: Publish Artifact
inputs:
targetPath: $(Build.SourcesDirectory)/${{ parameters.targetFolder }}
artifact: $(Build.SourceBranchName)-artifact
publishLocation: pipeline

- task: Npm@1
displayName: Staging - Repositorify Angular Demos and LOB Demos
condition: eq(variables['Build.SourceBranchName'], 'vNext')
inputs:
command: custom
workingDir: ${{ parameters.workingDir }}
verbose: false
customCommand: run repositoryfyAngularDemosLob

- task: Npm@1
displayName: Production - Repositorify Angular Demos
condition: and(eq(variables['Build.SourceBranchName'], 'master'), contains(variables['build.reason'], 'CI'))
inputs:
command: custom
workingDir: ${{ parameters.workingDir }}
verbose: false
customCommand: run repositoryfyAngularDemosLob:prod

- task: CmdLine@2
displayName: Stage changes
inputs:
script: git add .
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }}

- task: CmdLine@2
displayName: 'Check if there are any changes to be committed'
inputs:
script: |
# Check for changes
changeCount=$(git status --porcelain | wc -l)
if [ "$changeCount" -eq 0 ]; then
echo "##vso[task.logissue type=warning]No changes to commit."
exit 0
fi
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }}


- task: CmdLine@2
displayName: Commit changes
inputs:
script: git commit -m "Automated repository update"
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }}

- task: CmdLine@2
displayName: Push changes
inputs:
script: git push
workingDirectory: ${{ parameters.workingDir }}/igniteui-live-editing-samples/${{ parameters.submoduleDir }}

- task: PostBuildCleanup@4
displayName: Clean Agent Directories
condition: eq('${{ parameters.runCleanup }}', 'true')
Loading