@@ -20,24 +20,50 @@ concurrency:
20
20
cancel-in-progress : true
21
21
22
22
jobs :
23
+ get-branches :
24
+ runs-on : ubuntu-latest
25
+ outputs :
26
+ branches : ${{ steps.get-branches.outputs.branches }}
27
+ steps :
28
+ - uses : actions/checkout@v4
29
+
30
+ - name : Get list of remote branches and their hashes
31
+ id : get-branches
32
+ run : |
33
+ git fetch --all
34
+ branches="$(git for-each-ref --format='{"name":"%(refname:short)","hash":"%(objectname)"}' refs/remotes/origin/ | sed 's|origin/||' | jq -sc .)"
35
+ echo "branches=$branches" >> $GITHUB_OUTPUT
36
+
23
37
build :
24
38
runs-on : ubuntu-latest
39
+ needs : get-branches
40
+ continue-on-error : true
41
+ outputs :
42
+ branches : ${{ needs.get-branches.outputs.branches }}
43
+
44
+ strategy :
45
+ matrix :
46
+ branches : ${{fromJson(needs.get-branches.outputs.branches)}}
25
47
26
48
steps :
27
49
- uses : actions/checkout@v4
50
+ with :
51
+ ref : ${{ matrix.branches.name }}
28
52
29
53
- name : Use Node.js
30
54
uses : actions/setup-node@v4
31
55
32
56
- name : Build web app
33
57
run : |
58
+ [ -d "puck-ntag215-manager" ]
34
59
cd puck-ntag215-manager
35
60
npm install --no-optional
36
61
npm run build
37
-
62
+
38
63
- name : Upload artifact
39
- uses : actions/upload-pages- artifact@v3
64
+ uses : actions/upload-artifact@v4
40
65
with :
66
+ name : ${{ matrix.branches.hash }}
41
67
path : ./puck-ntag215-manager/dist/
42
68
43
69
# Deployment job
48
74
49
75
runs-on : ubuntu-latest
50
76
needs : build
77
+
51
78
steps :
79
+ - name : Download all artifacts
80
+ uses : actions/download-artifact@v4
81
+ with :
82
+ path : " artifacts"
83
+
84
+ - name : Prepare artifacts
85
+ env :
86
+ branches : ${{ needs.build.outputs.branches }}
87
+
88
+ run : |
89
+ mkdir -p "dist/"
90
+ echo "$branches" | jq -c '.[]' | while read -r branch; do
91
+ name="$(echo "$branch" | jq -r '.name')"
92
+ hash="$(echo "$branch" | jq -r '.hash')"
93
+
94
+ if [ "$name" == "master" ]; then
95
+ mv "artifacts/$hash"/* "dist/"
96
+ else
97
+ mkdir -p "dist/$name"
98
+ mv "artifacts/$hash"/* "dist/$name/"
99
+ fi
100
+ done
101
+
102
+ - name : Upload artifact
103
+ uses : actions/upload-pages-artifact@v3
104
+ with :
105
+ path : dist/
106
+
52
107
- name : Deploy to GitHub Pages
53
108
id : deployment
54
109
uses : actions/deploy-pages@v4
0 commit comments