Skip to content

Commit 451d732

Browse files
committed
feat(matrix): using matrix strategy for templated run
1 parent 410923d commit 451d732

1 file changed

Lines changed: 213 additions & 0 deletions

File tree

.github/workflows/cd-matrix.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: Continuous Deployment Matrix
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- vnext
8+
workflow_dispatch:
9+
workflow_dispatch:
10+
inputs:
11+
branch:
12+
description: 'Input a branch name (e.g., vnext)'
13+
required: true
14+
15+
env:
16+
REPLACEMENT_TEXT: '@infragistics/igniteui-angular-extras'
17+
BRANCH_REF: ${{ github.event.inputs.branch && format('refs/heads/{0}', github.event.inputs.branch) || github.ref }}
18+
19+
jobs:
20+
build-and-deploy:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
include:
25+
- name: app
26+
custom_command: run generate-live-editing
27+
submodule_dir: angular-demos
28+
base_href: /angular-demos/
29+
target_folder: dist/app
30+
npm_build_command: run build-ci
31+
repositoryfy: true
32+
repositoryfy_command: repositoryfyAngularDemos
33+
- name: app-crm
34+
custom_command: run generate-live-editing:app-crm
35+
submodule_dir: angular-demos-crm
36+
base_href: /angular-demos-grid-crm/
37+
target_folder: dist/app-crm
38+
npm_build_command: run build-ci:app-crm --loglevel verbose
39+
repositoryfy: false
40+
repositoryfy_command: ''
41+
- name: app-lob
42+
custom_command: run generate-live-editing:app-lob
43+
submodule_dir: angular-demos-lob
44+
base_href: /angular-demos-lob/
45+
target_folder: dist/app-lob
46+
npm_build_command: run build-ci:app-lob
47+
repositoryfy: true
48+
repositoryfy_command: repositoryfyAngularDemosLob
49+
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Setup Node.js
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: '22.x'
61+
62+
- name: Replace with licensed angular-extras
63+
shell: pwsh
64+
run: |
65+
# List of files to update
66+
$files = @(
67+
"projects/app-lob/src/app/grid-dynamic-chart-data/grid-dynamic-chart-data.component.ts",
68+
"projects/app-lob/src/app/grid-dynamic-chart-data/data-analysis-dock-manager/data-analysis-dock-manager.component.ts",
69+
"package.json")
70+
foreach ($file in $files) {
71+
if (Test-Path $file) {
72+
(Get-Content -Path $file) -replace 'igniteui-angular-extras', '${{ env.REPLACEMENT_TEXT }}' | Set-Content -Path $file
73+
}
74+
}
75+
76+
- name: Create .npmrc file
77+
run: touch .npmrc
78+
79+
- name: Configure npm registry
80+
run: |
81+
echo "@infragistics:registry=https://packages.infragistics.com/npm/js-licensed/" >> .npmrc
82+
echo "//packages.infragistics.com/npm/js-licensed/:_authToken=${{ secrets.INFRAGISTICS_NPM_TOKEN }}" >> .npmrc
83+
84+
- name: Install dependencies
85+
run: npm install
86+
env:
87+
GITHUB_ACTIONS: true
88+
89+
- name: Clone submodule
90+
run: git clone --recurse-submodules https://github.com/IgniteUI/igniteui-live-editing-samples igniteui-live-editing-samples
91+
92+
- name: Checkout branch in submodule (vNext)
93+
if: env.BRANCH_REF == 'refs/heads/vnext'
94+
run: |
95+
cd igniteui-live-editing-samples
96+
git checkout vNext
97+
98+
- name: Checkout branch in submodule (master)
99+
if: env.BRANCH_REF == 'refs/heads/master'
100+
run: |
101+
cd igniteui-live-editing-samples
102+
git checkout master
103+
104+
- name: Update package.json with base href
105+
run: |
106+
sed -i 's/--configuration production/--base-href=${{ matrix.base_href }} --configuration production/g' package.json
107+
108+
- name: Generate live-editing
109+
run: npm ${{ matrix.custom_command }}
110+
111+
- name: Update packages trial->licensed using angular schematics
112+
run: |
113+
npx --userconfig=./.npmrc ng g @igniteui/angular-schematics:upgrade-packages --skip-install
114+
115+
- name: Install dependencies after schematics
116+
run: npm install
117+
env:
118+
GITHUB_ACTIONS: true
119+
120+
- name: Build application
121+
run: npm ${{ matrix.npm_build_command }} --userconfig=./.npmrc
122+
123+
- name: Copy web.config
124+
run: |
125+
if [ -f "projects/app-crm/web.config" ]; then
126+
cp projects/app-crm/web.config ${{ matrix.target_folder }}/browser/
127+
fi
128+
129+
- name: Update web.config file
130+
run: |
131+
if [ -f "${{ matrix.target_folder }}/browser/web.config" ]; then
132+
sed -i 's/angular-demos/${{ matrix.submodule_dir }}/g' ${{ matrix.target_folder }}/browser/web.config
133+
fi
134+
135+
- name: Rename index.csr.html to index.html
136+
run: |
137+
if [ -f "${{ matrix.target_folder }}/browser/index.csr.html" ]; then
138+
mv "${{ matrix.target_folder }}/browser/index.csr.html" "${{ matrix.target_folder }}/browser/index.html"
139+
echo "File renamed successfully."
140+
fi
141+
142+
- name: Create zip artifact
143+
run: |
144+
cd ${{ matrix.target_folder }}/browser
145+
zip -r ../../${{ matrix.submodule_dir }}-artifact.zip ./
146+
147+
- name: Upload artifact
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: ${{ matrix.submodule_dir }}-artifact
151+
path: ${{ matrix.submodule_dir }}-artifact.zip
152+
153+
- name: Repositorify (vNext)
154+
if: env.BRANCH_REF == 'refs/heads/vnext' && matrix.repositoryfy == true
155+
run: npm run ${{ matrix.repositoryfy_command }}
156+
157+
- name: Repositorify (Production)
158+
if: env.BRANCH_REF == 'refs/heads/master' && matrix.repositoryfy == true
159+
run: npm run ${{ matrix.repositoryfy_command }}:prod
160+
161+
- name: Stage changes
162+
if: matrix.repositoryfy == true
163+
run: |
164+
cd igniteui-live-editing-samples/${{ matrix.submodule_dir }}
165+
git add .
166+
167+
- name: Check for changes
168+
if: matrix.repositoryfy == true
169+
id: check_changes
170+
run: |
171+
cd igniteui-live-editing-samples/${{ matrix.submodule_dir }}
172+
if [ -n "$(git status --porcelain)" ]; then
173+
echo "changes_detected=true" >> $GITHUB_OUTPUT
174+
else
175+
echo "changes_detected=false" >> $GITHUB_OUTPUT
176+
echo "No changes to commit."
177+
fi
178+
179+
- name: Configure git and commit changes
180+
if: matrix.repositoryfy == true && steps.check_changes.outputs.changes_detected == 'true'
181+
run: |
182+
cd igniteui-live-editing-samples/${{ matrix.submodule_dir }}
183+
git config --global user.name "github-actions[bot]"
184+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
185+
git commit -m "Automated repository update"
186+
187+
- name: Push changes
188+
if: matrix.repositoryfy == true && steps.check_changes.outputs.changes_detected == 'true'
189+
run: |
190+
cd igniteui-live-editing-samples/${{ matrix.submodule_dir }}
191+
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/IgniteUI/igniteui-live-editing-samples.git
192+
continue-on-error: true
193+
194+
- name: Trigger Deploy Workflow in IgniteUI Actions
195+
uses: actions/github-script@v8
196+
with:
197+
github-token: ${{ secrets.CLASSIC_PATKA }}
198+
script: |
199+
await github.rest.repos.createDispatchEvent({
200+
owner: 'IgniteUI',
201+
repo: 'igniteui-actions',
202+
event_type: 'igniteui-angular-samples-cd',
203+
client_payload: {
204+
repository: "${{ github.repository }}",
205+
run_id: "${{ github.run_id }}",
206+
artifact_name: "${{ matrix.submodule_dir }}-artifact",
207+
ref: "${{ github.ref }}",
208+
sha: "${{ github.sha }}",
209+
branch: '${{ github.ref_name }}',
210+
unit: false,
211+
integration: true
212+
}
213+
});

0 commit comments

Comments
 (0)