Skip to content

Commit

Permalink
Add ci for deploy docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjie2wang committed Mar 3, 2022
1 parent 6733141 commit 12fad6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
job:
script:
- bash misc/deploy_docs.sh
only:
- main
tags:
- droplets
- shell
32 changes: 32 additions & 0 deletions misc/deploy_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

## run on wenjie's droplets
pkg=$(grep "Package" DESCRIPTION | awk '{print $NF}')
build_dir=$(pwd)
docs_repo=$HOME/wenjie/wwenjie.org
target_dir=$docs_repo/static/$pkg
tmp_log=.git_status.log

## update docs by pkgdown
make pkgdown

# go to the repository for wwenjie.org
cd $docs_repo
git checkout -f
git checkout main
git pull origin main
mkdir -p $target_dir
cp -r $build_dir/docs/* $target_dir
git status > $tmp_log
cat $tmp_log
if egrep -q "modified:[ ]+static/$pkg/" $tmp_log
then
git add static/$pkg/
git commit -m "deploy $pkg $CI_COMMIT_SHORT_SHA by gitlab-runner"
git push origin main
else
printf "The docs was not updated.\n"
fi
rm $tmp_log

0 comments on commit 12fad6e

Please sign in to comment.