2019-05-21 21:53:54 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-08-07 13:43:26 +00:00
|
|
|
# check values
|
|
|
|
if [ -z "${GITHUB_TOKEN}" ]; then
|
|
|
|
echo "error: not found GITHUB_TOKEN"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${PUBLISH_BRANCH}" ]; then
|
|
|
|
echo "error: not found PUBLISH_BRANCH"
|
2019-05-21 21:53:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-26 13:37:08 +00:00
|
|
|
if [ -z "${PUBLISH_DIR}" ]; then
|
2019-05-21 21:53:54 +00:00
|
|
|
echo "error: not found PUBLISH_DIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-05-26 13:37:08 +00:00
|
|
|
cd "${PUBLISH_DIR}" || exit 1
|
2019-08-07 13:43:26 +00:00
|
|
|
|
|
|
|
# initialize git
|
|
|
|
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
2019-05-21 21:53:54 +00:00
|
|
|
remote_branch="${PUBLISH_BRANCH}"
|
|
|
|
git init
|
|
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
|
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
|
|
|
git remote add origin "${remote_repo}"
|
2019-08-07 13:43:26 +00:00
|
|
|
|
|
|
|
# push to publishing branch
|
2019-05-21 21:53:54 +00:00
|
|
|
git checkout "${remote_branch}" || git checkout --orphan "${remote_branch}"
|
|
|
|
git add --all
|
|
|
|
timestamp=$(date -u)
|
|
|
|
git commit -m "Automated deployment: ${timestamp} ${GITHUB_SHA}"
|
|
|
|
git push origin "${remote_branch}" --force
|