forked from opencobra/COBRA.tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
39 lines (29 loc) · 1.27 KB
/
build.sh
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
#!/bin/bash
DEST_REPO=$1
DEST_REPO_TOKEN=$2
FILE_PATH=$3
# Convert mlx to html using MATLAB command
# Note: Ensure that MATLAB is installed and added to the PATH
HTML_FILE_PATH=$(echo "$FILE_PATH" | sed 's/.mlx/.html/g')
export DISPLAY=:99
Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null & /home/aaron/Documents/Matlab/bin/matlab -batch "matlab.internal.liveeditor.openAndConvert('$FILE_PATH', '$HTML_FILE_PATH')"
# Clone the destination repository
git clone https://AaronBrennan1:[email protected]/$DEST_REPO.git
# Split the destination repository into owner and name
IFS='/' read -ra ADDR <<< "$DEST_REPO"
DEST_REPO_OWNER=${ADDR[0]}
DEST_REPO_NAME=${ADDR[1]}
# Change the current directory to the destination repository
cd $DEST_REPO_NAME
# Set up git config
git config user.name "GitHub Action"
git config user.email "[email protected]"
git checkout gh-pages
# Create the target directory in the destination repository
mkdir -p "stable/tutorials/$(dirname "$HTML_FILE_PATH")"
# Copy the file to the target directory in the destination repository
cp "../$HTML_FILE_PATH" "stable/tutorials/$HTML_FILE_PATH"
# Add, commit and push the files to the destination repository
git add .
git commit -m "Sync files from source repo" || echo "No changes to commit"
git push origin gh-pages