Skip to content

Commit

Permalink
Added Workflow File.
Browse files Browse the repository at this point in the history
  • Loading branch information
varunsridharan committed Jun 9, 2020
1 parent 35cf59e commit 9f7427e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/on-push.yml
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 }}

0 comments on commit 9f7427e

Please sign in to comment.