Skip to content

Commit 6a76434

Browse files
authored
Update CI for automatic deploys (#1)
* Updating CI * Testing machine image * Changing build dir to built * Running CI job * Added ssh key * Adding all files to built * Update CI config * temporary config changes * reverting temp change
1 parent 600ab4f commit 6a76434

File tree

2 files changed

+54
-24
lines changed

2 files changed

+54
-24
lines changed

.circleci/config.yml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ jobs:
77
build:
88
working_directory: ~/project
99
machine:
10-
image: 'ubuntu-1604:201903-01'
10+
image: 'ubuntu-2004:202107-02'
1111
steps:
12+
- add_ssh_keys:
13+
fingerprints:
14+
- "dc:5f:39:48:00:b4:72:34:e1:d2:c4:e1:1f:d1:e2:ce" #plotlydocbot
1215
- checkout:
1316
path: ~/project
1417
- restore_cache:
@@ -24,19 +27,46 @@ jobs:
2427
key: cache4
2528
paths:
2629
- "/usr/local/lib/R/site-library"
27-
- run:
28-
command: |
29-
sudo apt-get install tree
30-
tree
3130
- matlab/run-command:
3231
command: addpath(genpath('plotly_matlab/plotly/')); addpath(genpath('boundedline-pkg/')); addpath(genpath('ternplot/')); addpath(genpath('jdata/')); evalMD;
3332
- run:
33+
name: build site and perform front-matter checks
3434
command: |
35-
tree
36-
35+
echo ${mapbox_token} > .mapbox_token
36+
python3 -m venv venv
37+
. venv/bin/activate
38+
pip3 install python-frontmatter
39+
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/front-matter-ci.py > front-matter-ci.py
40+
python front-matter-ci.py built
41+
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/check-or-enforce-order.py > check-or-enforce-order.py
42+
python check-or-enforce-order.py built enforce
3743
- run:
38-
name: Compress Artifacts
39-
command: tar -cvzf tempF.tar tempF/
40-
- store_artifacts:
41-
path: tempF.tar
42-
destination: artifact-file
44+
name: deploy to plotly/plotly.matlab-docs:built
45+
command: |
46+
if [ "${CIRCLE_BRANCH}" == "main" ]; then
47+
cd built
48+
git init
49+
git config user.name plotlydocbot
50+
git config user.email [email protected]
51+
rm -rf *.html
52+
sed -i.bkp 's/<!--.*-->//g' *md && rm *.bkp # remove html comments
53+
sed -z -i.bkp 's/```{=html}\n<div/<div/g' *md && rm *.bkp # remove html backticks
54+
sed -z -i.bkp 's/script>\n```/script>/g' *md && rm *.bkp # remove html backticks
55+
git add *
56+
git commit -m "build of https://github.com/plotly/plotly.matlab-docs/commit/${CIRCLE_SHA1}"
57+
git push --force [email protected]:plotly/plotly.matlab-docs.git master:built
58+
rm -rf .git
59+
fi
60+
- run:
61+
name: trigger plotly/graphing-library-docs build
62+
command: |
63+
if [ "${CIRCLE_BRANCH}" == "main" ]; then
64+
git clone --depth=1 [email protected]:plotly/graphing-library-docs.git
65+
cd graphing-library-docs
66+
git config user.name plotlydocbot
67+
git config user.email [email protected]
68+
git commit --allow-empty -m "deploying https://github.com/plotly/plotly.matlab-docs/commit/${CIRCLE_SHA1}"
69+
git push
70+
cd ..
71+
rm -rf graphing-library-docs
72+
fi

evalMD.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
mdContents = arrayfun(@(x) replace(x,"```","&&&E"), mdContents);
1414

1515
mdContents = formCBs(mdContents);
16-
16+
1717
mdContents = arrayfun(@(x) replace(x,'&&&S','```{matlab}'), mdContents);
1818
mdContents = arrayfun(@(x) replace(x,'&&&E','```'), mdContents);
19-
19+
2020
mdContents = join(mdContents,newline);
21-
22-
if ~isfolder('tempF')
23-
mkdir('tempF');
21+
22+
if ~isfolder('built')
23+
mkdir('built');
2424
end
25-
25+
2626
[~,a,b]=fileparts(fileName);
27-
f = fopen(fullfile('tempF',fileList(i).name),'wb','ieee-le','UTF-8');
27+
f = fopen(fullfile('built',fileList(i).name),'wb','ieee-le','UTF-8');
2828
fwrite(f,mdContents,'char');
2929
fclose(f);
3030
close all force;
@@ -55,21 +55,21 @@
5555
tempStr = arrayfun(@(x) regexprep(x,"^plotly *\( *data *\)","pf=plotly(data,struct('writeFile',false))"), tempStr);
5656
tempStr = arrayfun(@(x) regexprep(x,"^plotly *\( *data *, *struct *\(","pf=plotly(data,struct('writeFile',false,"), tempStr);
5757
tempStr = arrayfun(@(x) regexprep(x,"p *= *plotlyfig *\( *gcf *","p=plotlyfig(gcf,'writeFile',false,'open',false"), tempStr);
58-
58+
5959
ss = strfind(tempStr,'plotly(','ForceCellOutput',true);
6060
ss = find(cellfun(@(x) ~isempty(x), ss, 'UniformOutput', true), 1);
6161

6262
ss2 = strfind(tempStr,'p.plotly','ForceCellOutput',true);
6363
ss2 = find(cellfun(@(x) ~isempty(x), ss2, 'UniformOutput', true), 1);
64-
64+
6565
if isempty(ss) && ~isempty(ss2)
6666
insTxt = "json = m2json(struct('data',{p.data},'layout',p.layout,'frames',{p.frames})); fprintf('%s\n',json); close all force;";
6767
else
6868
insTxt = "json = m2json(struct('data',{pf.data},'layout',pf.layout,'frames',{pf.frames})); fprintf('%s\n',json); close all force;";
6969
end
70-
70+
7171
ss=[ss,ss2];
72-
72+
7373
if ~isempty(ss)
7474
for j = 1:length(ss)
7575
if j>1
@@ -132,4 +132,4 @@
132132
res = ['<font color="red">...ERROR...<br>',ME.message,'</font>'];
133133
end
134134
end
135-
end
135+
end

0 commit comments

Comments
 (0)