forked from pashutk/chocofi
-
Notifications
You must be signed in to change notification settings - Fork 3
175 lines (167 loc) · 5.48 KB
/
main.yml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
on:
push:
branches:
- main
paths-ignore:
- '**/README.md'
- '**/LICENSE'
pull_request:
branches:
- main
paths-ignore:
- '**/README.md'
- '**/LICENSE'
workflow_dispatch:
paths-ignore:
- '**/README.md'
- '**/LICENSE'
env:
DOCKER_USER_OPTION: '$UID:$GID'
name: Build
jobs:
generate:
runs-on: ubuntu-latest
name: Generate
steps:
- name: Checkout
uses: actions/[email protected]
- uses: xanantis/docker-file-ownership-fix@v1
- name: Run build script
run: |
chmod +x build.sh
./build.sh
shell: bash
- name: Persist PCB gerbers
uses: actions/[email protected]
with:
name: Chocofi_pcb_gerbers
path: gerbers/pcb
- name: Persist case gerbers
uses: actions/[email protected]
with:
name: Chocofi_case_gerbers
path: gerbers/case
- name: Persist images
uses: actions/[email protected]
with:
name: Chocofi_images
path: images
image_matrix:
runs-on: ubuntu-latest
name: PCB image matrix
needs: generate
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
steps:
- uses: actions/download-artifact@master
with:
name: Chocofi_images
path: images
- id: setmatrix
run: |
matrixArray=$(find ./images -name 'pcb*.png' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB image files
# Start Generate JSON String
echo "$matrixArray" | \
jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
jq -sc "{ \"include\": .[] }" > tmp
cat ./tmp
# End Generate JSON String
matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
gerber_matrix:
runs-on: ubuntu-latest
name: Gerber matrix
needs: generate
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
steps:
- uses: actions/download-artifact@master
with:
name: Chocofi_pcb_gerbers
path: gerbers/pcb
- id: setmatrix
run: |
matrixArray=$(find ./gerbers/pcb -name '*.zip' | xargs -n 1 -i echo {} {} | sed 's# .*/# #') # Creates array of all PCB gerber files
# Start Generate JSON String
echo "$matrixArray" | \
jq --slurp --raw-input 'split("\n")[:-1] | map(split(" "))' | \
jq "map({\"filepath\": (.[0]), \"basename\": .[1] })" | \
jq -sc "{ \"include\": .[] }" > tmp
cat ./tmp
# End Generate JSON String
matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh wasn't cooperating
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
upload_pcb_gerbers:
runs-on: ubuntu-latest
name: Upload PCB gerbers
needs: [generate, gerber_matrix]
strategy:
matrix: ${{fromJson(needs.gerber_matrix.outputs.matrix)}}
steps:
- uses: actions/download-artifact@master
with:
name: Chocofi_pcb_gerbers
path: gerbers/pcb
- name: Gets latest created release info
id: latest_release_info
uses: jossef/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload gerbers
uses: shogo82148/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
overwrite: true
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
asset_path: ${{ matrix.filepath }}
asset_name: ${{ matrix.basename }}
upload_images:
runs-on: ubuntu-latest
name: Upload images
needs: [generate, image_matrix]
strategy:
matrix: ${{fromJson(needs.image_matrix.outputs.matrix)}}
steps:
- uses: actions/download-artifact@master
with:
name: Chocofi_images
path: images
- name: Gets latest created release info
id: latest_release_info
uses: jossef/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload images
uses: shogo82148/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
overwrite: true
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
asset_path: ${{ matrix.filepath }}
asset_name: ${{ matrix.basename }}
upload_gerber_case_files:
runs-on: ubuntu-latest
name: Upload case gerber files
needs: generate
steps:
- uses: actions/download-artifact@master
with:
name: Chocofi_case_gerbers
path: gerbers/case
- name: Gets latest created release info
id: latest_release_info
uses: jossef/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload case files
uses: shogo82148/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
overwrite: true
upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
asset_path: ./gerbers/case/gerber_case_files.zip
asset_name: gerber_case_files.zip