Update pages.yml
This commit is contained in:
parent
680f4aeb1e
commit
eae4d6c015
1 changed files with 30 additions and 6 deletions
36
.github/workflows/pages.yml
vendored
36
.github/workflows/pages.yml
vendored
|
|
@ -3,8 +3,6 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -15,28 +13,54 @@ jobs:
|
||||||
REMOTE="https://${GITHUB_PAT}@github.com/${GITHUB_REPOSITORY}.git"
|
REMOTE="https://${GITHUB_PAT}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
COMMITER_NAME="${GITHUB_ACTOR}-github-actions"
|
COMMITER_NAME="${GITHUB_ACTOR}-github-actions"
|
||||||
COMMITER_EMAIL="${GITHUB_ACTOR}-@users.noreply.github.com"
|
COMMITER_EMAIL="${GITHUB_ACTOR}-@users.noreply.github.com"
|
||||||
|
REMOTE_BRANCH_EXISTS=$(git ls-remote --heads ${REMOTE} ${target_branch} | wc -l)
|
||||||
|
|
||||||
echo "COMMITER_NAME: ${COMMITER_NAME}"
|
echo "COMMITER_NAME: ${COMMITER_NAME}"
|
||||||
echo "COMMITER_EMAIL: ${COMMITER_EMAIL}"
|
echo "COMMITER_EMAIL: ${COMMITER_EMAIL}"
|
||||||
echo "REMOTE: ${REMOTE}"
|
echo "REMOTE: ${REMOTE}"
|
||||||
|
|
||||||
|
|
||||||
mkdir /tmp/github-pages
|
mkdir /tmp/github-pages
|
||||||
cd /tmp/github-pages
|
cd /tmp/github-pages
|
||||||
|
|
||||||
|
if $keep_history && $REMOTE_BRANCH_EXISTS
|
||||||
|
then
|
||||||
|
git clone --quiet --branch ${target_branch} --depth 1 ${REMOTE} .
|
||||||
|
else
|
||||||
git init .
|
git init .
|
||||||
git checkout --orphan gh-pages
|
git checkout --orphan gh-pages
|
||||||
git status --short
|
fi
|
||||||
# git ls-remote --heads ${REMOTE} gh-pages
|
|
||||||
echo "<h1>hello there</h1>" > index.html
|
echo "<h1>hello there</h1>" > index.html
|
||||||
|
|
||||||
|
DIRTY=$(git status --short | wc -l)
|
||||||
|
|
||||||
|
if $keep_history && $REMOTE_BRANCH_EXISTS && [ DIRTY = 0 ]
|
||||||
|
then
|
||||||
|
echo '⚠️ There are no changes to commit, stopping.'
|
||||||
|
else
|
||||||
git config user.name ${COMMITER_NAME}
|
git config user.name ${COMMITER_NAME}
|
||||||
git config user.email ${COMMITER_EMAIL}
|
git config user.email ${COMMITER_EMAIL}
|
||||||
git status --porcelain
|
git status --porcelain
|
||||||
git add --all .
|
git add --all .
|
||||||
git commit -m "DIST to gh-pages"
|
git commit -m "DIST to ${target_branch}"
|
||||||
git push --quiet --force ${REMOTE} gh-pages
|
|
||||||
|
echo 🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo
|
||||||
|
|
||||||
|
if [ $keep_history == false]
|
||||||
|
then
|
||||||
|
git push --quiet ${REMOTE} ${target_branch}
|
||||||
|
else
|
||||||
|
git push --quiet --force ${REMOTE} ${target_branch}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo 🎉 Content of ${build_dir} has been deployed to GitHub Pages.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
|
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
|
||||||
|
target_branch: gh-pages
|
||||||
|
keep_history: true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue