OSDN Git Service

[update] : タイトル書き換えを追加
[alterlinux/hayao.fascode.net.git] / blog / update-theme.sh
1 #!/usr/bin/env bash
2
3 set -eu
4
5 script_path="$( cd -P "$( dirname "$(readlink -f "${0}")" )" && pwd )"
6 theme_dir="${script_path}/src/themes/"
7
8 cd "${theme_dir}"
9 for _theme in "${theme_dir}/"*; do
10     cd "${_theme}"
11     current_commit_id="$(git rev-parse --short HEAD)"
12     default_branch="$(git remote show origin | grep 'HEAD branch' | awk '{print $NF}')"
13     git checkout "${default_branch}"
14     git pull
15     new_commit_id="$(git rev-parse --short HEAD)"
16     cd "${script_path}"
17
18
19     if [[ ! "${current_commit_id}" = "${new_commit_id}" ]]; then
20         git add "${_theme}"
21         git commit -S -m "Updated hugo theme (${new_commit_id})"
22     fi
23
24     git push
25 done