1+ on :
2+ push :
3+ branches :
4+ - main
5+ paths-ignore :
6+ - ' **/README.md'
7+ - ' **/LICENSE'
8+ pull_request :
9+ branches :
10+ - main
11+ paths-ignore :
12+ - ' **/README.md'
13+ - ' **/LICENSE'
14+ workflow_dispatch :
15+ paths-ignore :
16+ - ' **/README.md'
17+ - ' **/LICENSE'
18+
19+ env :
20+ DOCKER_USER_OPTION : ' $UID:$GID'
21+
22+ name : Build
23+ jobs :
24+ generate :
25+ runs-on : ubuntu-latest
26+ name : Generate
27+ steps :
28+ - name : Checkout
29+ uses : actions/checkout@v2
30+ - uses : xanantis/docker-file-ownership-fix@v1
31+ - name : Run build script
32+ run : |
33+ chmod +x build.sh
34+ ./build.sh
35+ shell : bash
36+ - name : Persist PCB gerbers
37+ uses : actions/upload-artifact@v2
38+ with :
39+ name : Nijuni_pcb_gerbers
40+ path : gerbers/pcb
41+ - name : Persist case gerbers
42+ uses : actions/upload-artifact@v2
43+ with :
44+ name : Nijuni_case_gerbers
45+ path : gerbers/case
46+ - name : Persist images
47+ uses : actions/upload-artifact@v2
48+ with :
49+ name : Nijuni_images
50+ path : images
51+ - name : Persist laser case files
52+ uses : actions/upload-artifact@v2
53+ with :
54+ name : Nijuni_laser_case_files
55+ path : dxf
56+
57+
58+ image_matrix :
59+ runs-on : ubuntu-latest
60+ name : PCB image matrix
61+ needs : generate
62+ outputs :
63+ matrix : ${{ steps.setmatrix.outputs.matrix }}
64+ steps :
65+ - uses : actions/download-artifact@master
66+ with :
67+ name : Nijuni_images
68+ path : images
69+ - id : setmatrix
70+ run : |
71+ matrixArray=$(find ./images -name 'pcb*.png' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB image files
72+ # Start Generate JSON String
73+ echo "$matrixArray" | \
74+ jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
75+ jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
76+ jq -sc "{ \"include\": .[] }" > tmp
77+ cat ./tmp
78+ # End Generate JSON String
79+ matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
80+ echo "::set-output name=matrix::$matrixStringifiedObject"
81+
82+ gerber_matrix :
83+ runs-on : ubuntu-latest
84+ name : Gerber matrix
85+ needs : generate
86+ outputs :
87+ matrix : ${{ steps.setmatrix.outputs.matrix }}
88+ steps :
89+ - uses : actions/download-artifact@master
90+ with :
91+ name : Nijuni_gerbers
92+ path : gerbers
93+ - id : setmatrix
94+ run : |
95+ matrixArray=$(find ./gerbers/pcb -name '*.zip' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB gerber files
96+ # Start Generate JSON String
97+ echo "$matrixArray" | \
98+ jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
99+ jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
100+ jq -sc "{ \"include\": .[] }" > tmp
101+ cat ./tmp
102+ # End Generate JSON String
103+ matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
104+ echo "::set-output name=matrix::$matrixStringifiedObject"
105+
106+ upload_pcb_gerbers :
107+ runs-on : ubuntu-latest
108+ name : Upload gerbers
109+ needs : [generate, gerber_matrix]
110+ strategy :
111+ matrix : ${{fromJson(needs.gerber_matrix.outputs.matrix)}}
112+ steps :
113+ - uses : actions/download-artifact@master
114+ with :
115+ name : Nijuni_gerbers
116+ path : gerbers
117+ - name : Gets latest created release info
118+ id : latest_release_info
119+ uses : jossef/action-latest-release-info@v1.1.0
120+ env :
121+ GITHUB_TOKEN : ${{ github.token }}
122+ - name : Upload gerbers
123+ uses : shogo82148/actions-upload-release-asset@v1
124+ env :
125+ GITHUB_TOKEN : ${{ github.token }}
126+ with :
127+ overwrite : true
128+ upload_url : ${{ steps.latest_release_info.outputs.upload_url }}
129+ asset_path : ${{ matrix.filepath }}
130+ asset_name : ${{ matrix.basename }}
131+
132+ upload_images :
133+ runs-on : ubuntu-latest
134+ name : Upload images
135+ needs : [generate, image_matrix]
136+ strategy :
137+ matrix : ${{fromJson(needs.image_matrix.outputs.matrix)}}
138+ steps :
139+ - uses : actions/download-artifact@master
140+ with :
141+ name : Nijuni_images
142+ path : images
143+ - name : Gets latest created release info
144+ id : latest_release_info
145+ uses : jossef/action-latest-release-info@v1.1.0
146+ env :
147+ GITHUB_TOKEN : ${{ github.token }}
148+ - name : Upload images
149+ uses : shogo82148/actions-upload-release-asset@v1
150+ env :
151+ GITHUB_TOKEN : ${{ github.token }}
152+ with :
153+ overwrite : true
154+ upload_url : ${{ steps.latest_release_info.outputs.upload_url }}
155+ asset_path : ${{ matrix.filepath }}
156+ asset_name : ${{ matrix.basename }}
157+
158+ upload_laser_case_files :
159+ runs-on : ubuntu-latest
160+ name : Upload case DXF files
161+ needs : generate
162+ steps :
163+ - uses : actions/download-artifact@master
164+ with :
165+ name : Nijuni_laser_case_files
166+ path : dxf
167+ - name : Gets latest created release info
168+ id : latest_release_info
169+ uses : jossef/action-latest-release-info@v1.1.0
170+ env :
171+ GITHUB_TOKEN : ${{ github.token }}
172+ - name : Upload case files
173+ uses : shogo82148/actions-upload-release-asset@v1
174+ env :
175+ GITHUB_TOKEN : ${{ github.token }}
176+ with :
177+ overwrite : true
178+ upload_url : ${{ steps.latest_release_info.outputs.upload_url }}
179+ asset_path : ./dxf/laser_case_files.zip
180+ asset_name : laser_case_files.zip
181+
182+ upload_gerber_case_files :
183+ runs-on : ubuntu-latest
184+ name : Upload case DXF files
185+ needs : generate
186+ steps :
187+ - uses : actions/download-artifact@master
188+ with :
189+ name : Nijuni_gerber_case_files
190+ path : gerbers/case
191+ - name : Gets latest created release info
192+ id : latest_release_info
193+ uses : jossef/action-latest-release-info@v1.1.0
194+ env :
195+ GITHUB_TOKEN : ${{ github.token }}
196+ - name : Upload case files
197+ uses : shogo82148/actions-upload-release-asset@v1
198+ env :
199+ GITHUB_TOKEN : ${{ github.token }}
200+ with :
201+ overwrite : true
202+ upload_url : ${{ steps.latest_release_info.outputs.upload_url }}
203+ asset_path : ./gerbers/case/gerber_case_files.zip
204+ asset_name : gerber_case_files.zip
0 commit comments