-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d90a835
commit 535cf24
Showing
3 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
set -e | ||
|
||
# Check if deploy to same branch | ||
if [ "${REPOSITORY}" = "${GITHUB_REPOSITORY}" ]; then | ||
if [ "${GITHUB_REF}" = "refs/heads/${BRANCH}" ]; then | ||
if [[ "${REPOSITORY}" = "${GITHUB_REPOSITORY}" ]]; then | ||
if [[ "${GITHUB_REF}" = "refs/heads/${BRANCH}" ]]; then | ||
echo "It's conflicted to deploy on same branch ${BRANCH}" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Tell GitHub Pages not to run Jekyll | ||
touch .nojekyll | ||
[ -n "$INPUT_CNAME" ] && echo "$INPUT_CNAME" > CNAME | ||
[[ -n "$INPUT_CNAME" ]] && echo "$INPUT_CNAME" > CNAME | ||
|
||
# Prefer to use SSH approach when SSH private key is provided | ||
if [[ -n "${SSH_PRIVATE_KEY}" ]]; then | ||
REMOTE_REPO="ssh://[email protected]:${REPOSITORY}.git" | ||
echo SSH KEY PATH, ${SSH_PRIVATE_KEY_PATH} | ||
git config --add --local core.sshCommand "ssh -i ${SSH_PRIVATE_KEY_PATH}" | ||
else | ||
REMOTE_REPO="https://${ACTOR}:${TOKEN}@github.com/${REPOSITORY}.git" | ||
fi | ||
|
||
echo "Deploying to ${REPOSITORY} on branch ${BRANCH}" | ||
echo "Deploying to https://${ACTOR}:${TOKEN}@github.com/${REPOSITORY}.git" | ||
echo "Deploying to ${REMOTE_REPO}" | ||
|
||
REMOTE_REPO="https://${ACTOR}:${TOKEN}@github.com/${REPOSITORY}.git" && \ | ||
git config --global http.postBuffer 524288000 && \ | ||
git config --global init.defaultBranch main && \ | ||
git config --global init.defaultBranch main && \ | ||
git init && \ | ||
git config user.name "${ACTOR}" && \ | ||
git config user.email "${ACTOR}@users.noreply.github.com" && \ | ||
git add . && \ | ||
git commit -m "jekyll build from Action ${GITHUB_SHA}" && \ | ||
git push --force $REMOTE_REPO main:$BRANCH && \ | ||
fuser -k .git || rm -rf .git && \ | ||
(fuser -k .git || rm -rf .git) && \ | ||
cd .. | ||
|
||
exit $? |