Skip to content

Commit 611b207

Browse files
authored
Merge pull request #3773 from IgniteUI/sstoychev/cd-trigger-yml
Adding CD matrix ymls
2 parents 9b1be31 + f8c7006 commit 611b207

File tree

2 files changed

+282
-13
lines changed

2 files changed

+282
-13
lines changed

.github/workflows/cd-matrix.yml

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

.github/workflows/deploy-trigger.yml

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,71 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- name: Trigger Workflow in Another Repository
22-
env:
23-
GH_TOKEN: ${{ secrets.CLASSIC_PATKA }}
21+
- name: Debug Token Availability
2422
run: |
25-
# Set the required variables
26-
repo="IgniteUI/igniteui-actions"
27-
event_type="igniteui-angular-samples-cd"
28-
branch="${{ github.ref_name }}"
29-
30-
# Trigger repository dispatch using GitHub CLI
31-
gh api repos/$repo/dispatches \
32-
--method POST \
33-
--field event_type="$event_type" \
34-
--raw-field client_payload="{\"branch\": \"$branch\", \"unit\": false, \"integration\": true}"
23+
if [ -z "${{ secrets.CLASSIC_PATKA }}" ]; then
24+
echo "CLASSIC_PATKA secret is not set or is empty"
25+
echo "Will fallback to github.token"
26+
else
27+
echo "CLASSIC_PATKA secret is available"
28+
fi
29+
30+
- name: Setup Node for Github CLI
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '24.x'
34+
35+
- name: Create Dummy Artifact
36+
run: |
37+
# Create a directory for the artifact
38+
mkdir -p artifact-output
39+
40+
# Create some dummy files with deployment information
41+
echo "Deployment triggered successfully" > artifact-output/deployment-status.txt
42+
echo "Branch: ${{ github.ref_name }}" >> artifact-output/deployment-status.txt
43+
echo "Commit: ${{ github.sha }}" >> artifact-output/deployment-status.txt
44+
echo "Timestamp: $(date)" >> artifact-output/deployment-status.txt
45+
echo "Repository: ${{ github.repository }}" >> artifact-output/deployment-status.txt
46+
47+
# Create a JSON file with deployment metadata
48+
cat > artifact-output/deployment-metadata.json << EOF
49+
{
50+
"branch": "${{ github.ref_name }}",
51+
"commit": "${{ github.sha }}",
52+
"repository": "${{ github.repository }}",
53+
"trigger_event": "${{ github.event_name }}",
54+
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
55+
"deployment_triggered": true
56+
}
57+
EOF
58+
59+
# List the created files
60+
ls -la artifact-output/
61+
62+
- name: Upload Deployment Artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: deployment-trigger-info
66+
path: artifact-output/
67+
retention-days: 30
68+
69+
- name: Trigger Workflow in Another Repository
70+
uses: actions/github-script@v8
71+
with:
72+
github-token: ${{ secrets.CLASSIC_PATKA || github.token }}
73+
script: |
74+
await github.rest.repos.createDispatchEvent({
75+
owner: 'IgniteUI',
76+
repo: 'igniteui-actions',
77+
event_type: 'igniteui-angular-samples-cd',
78+
client_payload: {
79+
repository: "${{ github.repository }}",
80+
run_id: "${{ github.run_id }}",
81+
artifact_name: "deployment-trigger-info",
82+
ref: "${{ github.ref }}",
83+
sha: "${{ github.sha }}",
84+
branch: '${{ github.ref_name }}',
85+
unit: false,
86+
integration: true
87+
}
88+
});

0 commit comments

Comments
 (0)