forked from victoriadrake/hugo-remote
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.sh
executable file
·41 lines (34 loc) · 1.17 KB
/
action.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
#!/bin/bash
# Fail if variables are unset
set -eu -o pipefail
echo '🔧 Install tools'
npm init -y && npm install -y postcss-cli autoprefixer
echo '🤵 Install Hugo'
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r '.tag_name')
mkdir tmp/ && cd tmp/
curl -sSL https://github.com/gohugoio/hugo/releases/download/${HUGO_VERSION}/hugo_extended_${HUGO_VERSION: -6}_Linux-64bit.tar.gz | tar -xvzf-
mv hugo /usr/local/bin/
cd .. && rm -rf tmp/
cd ${GITHUB_WORKSPACE}
hugo version || exit 1
echo '👯 Clone remote repository'
git clone https://github.com/${REMOTE} ${DEST} --branch master
echo '🧹 Clean site'
if [ -d "${DEST}" ]; then
rm -rf ${DEST}/*
fi
echo '🍳 Build site'
hugo -d ${DEST} ${ARGS}
echo '🎁 Publish to remote repository'
cd ${DEST}
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -am "🚀 Deploy with ${GITHUB_WORKFLOW}"
git remote add publisher "https://${USER}:${TOKEN}@github.com/${REMOTE}"
git remote -v
git push -fq publisher master
else
echo 'No changes to build :)'
fi