generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action_entrypoint.sh
executable file
·48 lines (38 loc) · 1.53 KB
/
action_entrypoint.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
40
41
42
43
44
45
46
#!/bin/bash
set -e
# setup ssh: allow key to be used without a prompt and start ssh agent
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
eval "$(ssh-agent -s)"
######## Run notebook/word converter ########
# word converter using pandoc
/fastpages/word2post.sh
# notebook converter using nbdev
cp /fastpages/settings.ini .
python /fastpages/nb2post.py
######## Optionally save files and build GitHub Pages ########
if [[ "$INPUT_BOOL_SAVE_MARKDOWN" == "true" ]];then
if [ -z "$INPUT_SSH_DEPLOY_KEY" ];then
echo "You must set the SSH_DEPLOY_KEY input if BOOL_SAVE_MARKDOWN is set to true.";
exit 1;
fi
# Get user's email from commit history
if [[ "$GITHUB_EVENT_NAME" == "push" ]];then
USER_EMAIL=`cat $GITHUB_EVENT_PATH | jq '.commits | .[0] | .author.email'`
else
USER_EMAIL="[email protected]"
fi
# Setup Git credentials if we are planning to change the data in the repo
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$USER_EMAIL"
git remote add fastpages-origin "[email protected]:$GITHUB_REPOSITORY.git"
echo "${INPUT_SSH_DEPLOY_KEY}" > _mykey
chmod 400 _mykey
ssh-add _mykey
# Optionally save intermediate markdown
if [[ "$INPUT_BOOL_SAVE_MARKDOWN" == "true" ]]; then
git pull fastpages-origin ${GITHUB_REF} --ff-only
git add _posts
git commit -m "[Bot] Update $INPUT_FORMAT blog posts" --allow-empty
git push fastpages-origin HEAD:${GITHUB_REF}
fi
fi