generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (91 loc) · 3.56 KB
/
check-changes-npm-packages.yaml
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
95
96
97
98
99
100
101
102
# Run it locally with act
# 1. Install act:
# `brew install act`
# 2. Create a .secret file with the following content:
# `GITHUB_TOKEN=your_github_token`
# PULL REQUEST
# 1. Create a act_pull_request.json file in case of a pull request with the following content:
# `{"pull_request": {"number": <PR number>, "head": {"ref": "<PR branch name>", "sha": "PR commit sha"}, "base": {"ref": "main"}}, "repository": {"name": "juno", "owner": {"login": "cloudoperators"}}}`
# 2. Run the following command:
# `act pull_request --container-architecture linux/amd64 -P default=catthehacker/ubuntu:act-latest -j run-ci-npm-package -e act_pull_request.json`
name: Detect Changes and trigger Pipeline
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "apps/**"
- "libs/**"
jobs:
detect-changes:
runs-on: [default]
outputs:
changes: ${{ steps.create-matrix-changes.outputs.changes}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate app and lib filters
run: |
for folder in apps/*; do
folder_name=$(basename "$folder")
echo "$folder_name: $folder/**" >> temp_app_filters.yaml
done
for folder in libs/*; do
folder_name=$(basename "$folder")
echo "$folder_name: $folder/**" >> temp_lib_filters.yaml
done
- uses: dorny/paths-filter@v3
id: filters
with:
list-files: shell
filters: |
apps: apps/**
libs: libs/**
- uses: dorny/paths-filter@v3
id: app-filters
with:
list-files: shell
filters: temp_app_filters.yaml
- uses: dorny/paths-filter@v3
id: lib-filters
with:
list-files: shell
filters: temp_lib_filters.yaml
- name: Create changes array for the matrix strategy
id: create-matrix-changes
run: |
app_changes=$(echo '${{ steps.app-filters.outputs.changes }}' | jq -c '.[]')
lib_changes=$(echo '${{ steps.lib-filters.outputs.changes }}' | jq -c '.[]')
changes=()
for app in $app_changes; do
changes+=( "{\"type\":\"apps\",\"asset\":$app}" )
done
for change in $lib_changes; do
changes+=( "{\"type\":\"libs\",\"asset\":$change}" )
done
echo "changes=[$(IFS=,; echo "${changes[*]}")]" >> $GITHUB_OUTPUT
- name: Show outputs
run: |
echo "===${{ github.workflow }} Outputs==="
cat temp_app_filters.yaml
echo "========"
cat temp_lib_filters.yaml
echo "========"
echo apps: ${{ steps.filters.outputs.apps}}
echo apps_files: ${{ steps.filters.outputs.apps_files}}
echo app changes: ${{ steps.app-filters.outputs.changes}}
echo libs: ${{ steps.filters.outputs.libs}}
echo libs_files: ${{ steps.filters.outputs.libs_files}}
echo lib changes: ${{ steps.lib-filters.outputs.changes}}
echo changes: ${{ toJson(steps.create-matrix-changes.outputs.changes) }}
echo "===================="
run-ci-npm-package:
needs: [detect-changes]
strategy:
matrix:
change: ${{fromJson(needs.detect-changes.outputs.changes)}}
node: [20.x]
fail-fast: false # Allow other jobs to continue if one fails
uses: cloudoperators/juno/.github/workflows/pipeline-npm-package.yaml@workflows-name-convention
with:
change: ${{ toJson(matrix.change) }}
node: "${{ matrix.node }}"