-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·64 lines (51 loc) · 1.82 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·64 lines (51 loc) · 1.82 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
set -e
echo "Starting the Jekyll Action"
if [ -z "${JEKYLL_PAT}" ]; then
echo "No token provided. Please set the JEKYLL_PAT environment variable."
exit 1
fi
if [ -n "${INPUT_GEM_SRC}" ]; then
cd ${INPUT_GEM_SRC}
echo "::debug ::Working directory$(pwd)"
fi
echo "::debug ::Starting bundle install"
bundle config path vendor/bundle
bundle install
echo "::debug ::Completed bundle install"
if [ -n "${INPUT_JEKYLL_SRC}" ]; then
JEKYLL_SRC=${INPUT_JEKYLL_SRC}
echo "::debug ::Using parameter value ${JEKYLL_SRC} as a source directory"
elif [ -n "${SRC}" ]; then
JEKYLL_SRC=${SRC}
echo "::debug ::Using SRC environment var value ${JEKYLL_SRC} as a source directory"
else
JEKYLL_SRC=$(find . -path ./vendor/bundle -prune -o -name '_config.yml' -exec dirname {} \;)
echo "::debug ::Resolved ${JEKYLL_SRC} as a source directory"
fi
JEKYLL_ENV=production bundle exec jekyll build -s ${JEKYLL_SRC} -d build
echo "Jekyll build done"
cd build
# No need to have GitHub Pages to run Jekyll
touch .nojekyll
# Is this a regular repo or an org.github.io type of repo
case "${GITHUB_REPOSITORY}" in
*.github.io) remote_branch="master" ;;
*) remote_branch="gh-pages" ;;
esac
if [ "${GITHUB_REF}" = "refs/heads/${remote_branch}" ]; then
echo "Cannot publish on branch ${remote_branch}"
exit 1
fi
echo "Publishing to ${GITHUB_REPOSITORY} on branch ${remote_branch}"
echo "::debug ::Pushing to https://${JEKYLL_PAT}@github.com/${GITHUB_REPOSITORY}.git"
remote_repo="https://${JEKYLL_PAT}@github.com/${GITHUB_REPOSITORY}.git" && \
git init && \
git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
git add . && \
git commit -m "jekyll build from Action ${GITHUB_SHA}" && \
git push --force $remote_repo master:$remote_branch && \
rm -fr .git && \
cd ..
exit $?