mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-22 07:20:05 +00:00
roles/blog: run updateBlog; now idempotent!
This commit is contained in:
parent
4359544b6a
commit
41ef83bb4e
@ -4,18 +4,18 @@
|
|||||||
repo: "https://github.com/CPunch/openpunk.git"
|
repo: "https://github.com/CPunch/openpunk.git"
|
||||||
dest: "/var/www/{{ domain }}"
|
dest: "/var/www/{{ domain }}"
|
||||||
|
|
||||||
# TODO: make idempotent (call the updateBlog script !!)
|
|
||||||
- name: Build blog
|
|
||||||
command:
|
|
||||||
cmd: hugo
|
|
||||||
chdir: "/var/www/{{ domain }}"
|
|
||||||
|
|
||||||
- name: Install updateBlog script
|
- name: Install updateBlog script
|
||||||
template:
|
template:
|
||||||
src: templates/updateBlog
|
src: templates/updateBlog
|
||||||
dest: /usr/local/bin/updateBlog
|
dest: /usr/local/bin/updateBlog
|
||||||
mode: u+rx
|
mode: u+rx
|
||||||
|
|
||||||
|
- name: Build blog
|
||||||
|
command:
|
||||||
|
cmd: updateBlog
|
||||||
|
register: blog_out
|
||||||
|
changed_when: blog_out.stdout != "up to date"
|
||||||
|
|
||||||
# Rebuild blog every hour
|
# Rebuild blog every hour
|
||||||
- name: Setup blog cron job
|
- name: Setup blog cron job
|
||||||
cron:
|
cron:
|
||||||
|
@ -15,16 +15,14 @@ LOCAL=$(git rev-parse @)
|
|||||||
REMOTE=$(git rev-parse "$UPSTREAM")
|
REMOTE=$(git rev-parse "$UPSTREAM")
|
||||||
BASE=$(git merge-base @ "$UPSTREAM")
|
BASE=$(git merge-base @ "$UPSTREAM")
|
||||||
if [ $LOCAL = $REMOTE ]; then
|
if [ $LOCAL = $REMOTE ]; then
|
||||||
echo "blog is up to date!"
|
echo "up to date"
|
||||||
elif [ $LOCAL = $BASE ]; then
|
elif [ $LOCAL = $BASE ]; then
|
||||||
# there are changes to reset too
|
# there are changes to reset too
|
||||||
# && we need to update our blog
|
# && we need to update our blog
|
||||||
echo "missing changes!!"
|
echo "missing changes!!"
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
buildBlog
|
buildBlog
|
||||||
fi
|
elif [ ! -d "$PUBLIC_DIR" ] || [ ! -d "$TOR_DIR" ]; then
|
||||||
|
|
||||||
if [ ! -d "$PUBLIC_DIR" ] || [ ! -d "$TOR_DIR" ]; then
|
|
||||||
echo "missing directories..."
|
echo "missing directories..."
|
||||||
buildBlog
|
buildBlog
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue
Block a user