-
Notifications
You must be signed in to change notification settings - Fork 0
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
35cf59e
commit 9f7427e
Showing
1 changed file
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: On Push | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
Update_GH_Pages: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetching Repository | ||
uses: actions/checkout@v2 | ||
- name: Generating HTML | ||
uses: nanasess/setup-php@master | ||
with: | ||
php-version: '7.3' | ||
- run: php generator.php $GITHUB_SHA | ||
- run: | | ||
cd ../ | ||
git config --global user.email "whystopusingchinese@yahoo.com" && git config --global user.name "Website Regenerated" | ||
PUSH_TO_BRANCH="gh-pages" | ||
if [ -z "$(git ls-remote --heads https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git ${PUSH_TO_BRANCH})" ]; then | ||
git clone --quiet https://x-access-token:$GITHUB_TOKEN@github.com/${GITHUB_REPOSITORY}.git $PUSH_TO_BRANCH >/dev/null | ||
cd $PUSH_TO_BRANCH | ||
git checkout --orphan $PUSH_TO_BRANCH >/dev/null | ||
git rm -rf . >/dev/null | ||
echo "$GITHUB_REPOSITORY" >README.md | ||
git add README.md | ||
git commit -a -m "➕ Create $PUSH_TO_BRANCH Branch" | ||
git push origin $PUSH_TO_BRANCH | ||
cd .. | ||
echo "🗃 $PUSH_TO_BRANCH Created" | ||
else | ||
echo "👌 $PUSH_TO_BRANCH Clone Log" | ||
git clone --quiet --branch=$PUSH_TO_BRANCH https://x-access-token:$GITHUB_TOKEN@github.com/${GITHUB_REPOSITORY}.git $PUSH_TO_BRANCH | ||
fi | ||
cp -r $GITHUB_WORKSPACE/output/* $PUSH_TO_BRANCH/ | ||
cd $PUSH_TO_BRANCH/ | ||
if [ "$(git status --porcelain)" != "" ]; then | ||
echo "👌 Website Published" | ||
git add . | ||
git commit -m "📖 #$GITHUB_RUN_NUMBER - Website Regenerated / ⚡ Triggered By $GITHUB_SHA" | ||
git push origin $PUSH_TO_BRANCH | ||
else | ||
echo "✅ Nothing To Push" | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |