-
Notifications
You must be signed in to change notification settings - Fork 6
121 lines (99 loc) · 3.5 KB
/
mechanical_components.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
name: mechanical_components
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/mechanical_components.yml'
- '.github/workflows/freecad_export.py'
- '.github/workflows/openscad_preview.sh'
- 'Mechanical/Design/**'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
generate-artifacts:
name: freecad export
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component:
- 'KNOT-FRONT'
- 'KNOT-BACK'
- 'KNOT-HOUSING'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb x11vnc
sudo apt-get install snapd
sudo snap install freecad
sudo apt-get install -y openscad
Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
sleep 10 # Give Xvfb some time to start
x11vnc -display :99 -nopw -listen localhost -xkb -ncache 10 -ncache_cr -forever > /dev/null 2>&1 &
- name: Run GUI application
continue-on-error: true
run: |
ls
export DISPLAY=:99
timeout 5m freecad --hidden ./Mechanical/Design/${{ matrix.component }}/${{ matrix.component }}.FCStd ./.github/workflows/freecad_export.py step pdf
- name: Install conda, pythonocc and do the conversion
run: |
CONDA_INSTALL_DIR="$HOME/miniconda3"
# Download and install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p "$CONDA_INSTALL_DIR"
rm miniconda.sh
# Add Miniconda to PATH
export PATH="$CONDA_INSTALL_DIR/bin:$PATH"
# Initialize conda
conda init bash
# Print Miniconda version
conda --version
conda install -c conda-forge pythonocc-core=7.7.2 --yes
conda --version
python ./.github/workflows/pythonocc_step_to_stl.py
- name: Generate Preview PNG
run: |
./.github/workflows/openscad_preview.sh
- name: Stop x11vnc
run: pkill x11vnc
- name: Set Date
run: echo "action_date=$(date +'%Y-%m-%d-%H%M')" >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "result_${{ matrix.component }}_${{ env.action_date }}"
path: temp/*.*
deploy-results:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: generate-artifacts
steps:
- uses: actions/checkout@v2
with:
ref: preview
- name: Download reports' artifacts
uses: actions/download-artifact@v4
with:
path: download
- name: Collecting files
run: |
# Create the temp folder if it doesn't exist
mkdir -p Preview/Mechanical
# Loop through each subdirectory in the download folder
for subdirectory in download/*; do
# Check if it is a directory
if [ -d "$subdirectory" ]; then
# Copy the contents of the subdirectory to the temp folder
cp -r "$subdirectory"/* "Preview/Mechanical/"
fi
done
- name: Commit the files
run: |
git config --global user.name ${{ github.actor }}
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git add Preview/*
git commit -m "BOT ${{ github.workflow }} ${{ github.sha }}"
git push