Fix entrypoint
This commit is contained in:
parent
67dc5c0b45
commit
4baa844a73
|
@ -10,7 +10,6 @@ LABEL version="0.1.0" \
|
||||||
"com.github.actions.icon"="package" \
|
"com.github.actions.icon"="package" \
|
||||||
"com.github.actions.color"="green"
|
"com.github.actions.color"="green"
|
||||||
|
|
||||||
COPY entrypoint.sh LICENSE README.md /
|
COPY LICENSE README.md /
|
||||||
RUN chmod a+x /entrypoint.sh
|
ADD entrypoint.sh /
|
||||||
|
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_DIR=$1
|
BUILD_DIR=$1
|
||||||
if [ ! -d "$BUILD_DIR" ]; then
|
if [ ! -d "$BUILD_DIR" ]; then
|
||||||
echo "⛔️ Build dir does not exist"
|
echo "⛔️ Build dir does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "cd $BUILD_DIR"
|
echo "cd $BUILD_DIR"
|
||||||
cd "$BUILD_DIR"
|
cd "$BUILD_DIR"
|
||||||
|
|
||||||
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
OWNER="$(echo $GITHUB_REPOSITORY | cut -d'/' -f 1)"
|
OWNER="$(echo $GITHUB_REPOSITORY | cut -d'/' -f 1)"
|
||||||
REPONAME="$(echo $GITHUB_REPOSITORY | cut -d'/' -f 2)"
|
REPONAME="$(echo $GITHUB_REPOSITORY | cut -d'/' -f 2)"
|
||||||
PAGES_REPO="${OWNER}.github.io"
|
PAGES_REPO="${OWNER}.github.io"
|
||||||
|
|
||||||
if [[ "$REPONAME" == "$PAGES_REPO" ]]; then
|
if [[ "$REPONAME" == "$PAGES_REPO" ]]; then
|
||||||
TARGET_BRANCH="master"
|
TARGET_BRANCH="master"
|
||||||
else
|
else
|
||||||
TARGET_BRANCH="gh-pages"
|
TARGET_BRANCH="gh-pages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: "${REMOTE_BRANCH:=$TARGET_BRANCH}"
|
: "${REMOTE_BRANCH:=$TARGET_BRANCH}"
|
||||||
|
|
||||||
git init
|
git init
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
|
|
||||||
if [ -z "$(git status --porcelain)" ]; then
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
echo "⚠️ Nothing to publish"
|
echo "⚠️ Nothing to publish"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git remote rm origin || true
|
git remote rm origin || true
|
||||||
git remote add origin "${REPO}"
|
git remote add origin "${REPO}"
|
||||||
git add .
|
git add .
|
||||||
git commit --allow-empty -m 'Deploy to GitHub pages'
|
git commit --allow-empty -m 'Deploy to GitHub pages'
|
||||||
git push --force --quiet "$REPO" $REMOTE_BRANCH
|
git push --force --quiet "$REPO" $REMOTE_BRANCH
|
||||||
rm -rf .git
|
rm -rf .git
|
||||||
|
|
||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
echo "🎉 Content of $BUILD_DIR has been deployed to GitHub Pages."
|
echo "🎉 Content of $BUILD_DIR has been deployed to GitHub Pages."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user