-
Notifications
You must be signed in to change notification settings - Fork 45
107 lines (103 loc) · 3.42 KB
/
netlify-test.yaml
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
name: Deploy website to Netlify and build notebooks
on:
pull_request:
branches:
- main
- master
- dev
jobs:
blogdown:
name: Render-Blog
runs-on: ubuntu-latest
container: linogaliana/python-datascientist:latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Install rmarkdown
env:
GITHUB_PAT: ${{ secrets.PAT_GITHUB }}
run: |
Rscript -e 'install.packages(c("rmarkdown"))'
- name: install hugo
run: Rscript -e 'blogdown::install_hugo("0.83.0", force = TRUE)'
- name: Install Python
run: |
Rscript -e 'print(blogdown:::hugo_version())'
Rscript -e "install.packages(c('remotes', 'reticulate'))"
Rscript -e "install.packages(c('here'))"
- shell: bash -l {0}
run: |
conda info
conda list
- name: Build to md
run: |
Rscript -e 'source("./build/build_light.R")'
- name: Clean files with Python function
run: |
rm -rf "./temp"
mkdir -p temp
mkdir -p notebooks
pip install matplotlib wordcloud nltk
python build/cleanmd.py
python build/wc_website.py
- name: Render blog
run: |
Rscript -e 'source("./build/netlify.R")'
- name: Install npm
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: actions/setup-node@v2
with:
node-version: '12'
- name: Deploy to Netlify
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
# NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID added in the repo's secrets
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
BRANCHE_REF: ${{ github.event.pull_request.head.ref }}
run: |
npm init -y
npm install --unsafe-perm=true netlify-cli -g
netlify init
netlify deploy --alias=${BRANCHE_REF} --dir="public" --message "Preview deploy from ${BRANCHE_REF}"
- uses: actions/upload-artifact@v1
with:
name: content
path: content/
- name: Convert in ipynb with Jupytext
run: |
pip install jupytext
cd ./temp
for i in $(find . -type f \( -iname "*.Rmd" \)); do \
j="${i%.Rmd}.md" ;
echo "$j" ;
if [ -e $j ]
then
echo "Converting $j"; \
#jupytext --to py --execute "$i"
jupytext --to ipynb "$j" ;
k="${j%.md}.ipynb" ;
fi
done
mkdir -p ../notebooks
cp -R . ../notebooks
cd ..
- uses: actions/upload-artifact@v2
with:
name: Notebooks
path: temp/
- name: Commit new notebooks
env:
BRANCHE_REF: ${{ github.event.pull_request.head.ref }}
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
# git config user.email github-actions@github.com
#git checkout ${BRANCHE_REF}
git status
git add notebooks/**/*.ipynb;
git commit -m "Automated changes";
git push