mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Checks to see if the remote branch exists
This commit is contained in:
parent
7e7e6c8e3f
commit
448be22c60
@ -28,9 +28,6 @@ then
|
|||||||
COMMIT_NAME="${GITHUB_ACTOR}"
|
COMMIT_NAME="${GITHUB_ACTOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Initializes the repository path using the access token.
|
|
||||||
REPOSITORY_PATH="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
|
|
||||||
|
|
||||||
# Installs Git.
|
# Installs Git.
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y git && \
|
apt-get install -y git && \
|
||||||
@ -38,12 +35,32 @@ apt-get install -y git && \
|
|||||||
# Directs the action to the the Github workspace.
|
# Directs the action to the the Github workspace.
|
||||||
cd $GITHUB_WORKSPACE && \
|
cd $GITHUB_WORKSPACE && \
|
||||||
|
|
||||||
# Configures Git and checks out the base branch.
|
# Configures Git.
|
||||||
git init && \
|
git init && \
|
||||||
git config --global user.email "${COMMIT_EMAIL}" && \
|
git config --global user.email "${COMMIT_EMAIL}" && \
|
||||||
git config --global user.name "${COMMIT_NAME}" && \
|
git config --global user.name "${COMMIT_NAME}" && \
|
||||||
|
|
||||||
|
## Checks to see if the remote exists prior to deploying
|
||||||
|
REMOTE_BRANCH = `git ls-remote --heads "https://${ACCESS_TOKEN}@github.com:JamesIves/reddit-viewer.git" docs`
|
||||||
|
|
||||||
|
# If the branch doesn't exist it gets created here as an orphan.
|
||||||
|
if [[ -z $REMOTE_BRANCH ]]
|
||||||
|
then
|
||||||
|
git checkout --orphan $BRANCH && \
|
||||||
|
git rm -rf . && \
|
||||||
|
touch README.md && \
|
||||||
|
git add README.md && \
|
||||||
|
git commit -m "Initial ${BRANCH} commit" && \
|
||||||
|
git push origin $BRANCH
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checks out the base branch to begin the deploy process.
|
||||||
git checkout "${BASE_BRANCH:-master}" && \
|
git checkout "${BASE_BRANCH:-master}" && \
|
||||||
|
|
||||||
|
## Initializes the repository path using the access token.
|
||||||
|
REPOSITORY_PATH="https://${ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
|
||||||
|
|
||||||
|
|
||||||
# Builds the project if a build script is provided.
|
# Builds the project if a build script is provided.
|
||||||
echo "Running build scripts... $BUILD_SCRIPT"
|
echo "Running build scripts... $BUILD_SCRIPT"
|
||||||
eval "$BUILD_SCRIPT"
|
eval "$BUILD_SCRIPT"
|
||||||
|
Loading…
Reference in New Issue
Block a user