Deploy 12 Days ALife #385
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
name: Deploy 12 Days ALife | |
on: | |
schedule: | |
- cron: '30 0 * * *' # minimum interval is 5 minutes | |
env: | |
BASE_BRANCH_NAME: main | |
HOSTING_BRANCH_NAME: gh-pages | |
LOCAL_BRANCH_NAME: gh-pages-local | |
jobs: | |
Deploy-12Days-ALife: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.6.7' | |
- name: Setup git | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
cd $GITHUB_WORKSPACE | |
git fetch | |
- name: Clean up | |
continue-on-error: true | |
run: | | |
git branch -d $LOCAL_BRANCH_NAME | |
- name: Checkout | |
run: | | |
git fetch | |
git checkout $BASE_BRANCH_NAME | |
git pull | |
git checkout -b $LOCAL_BRANCH_NAME | |
- name: Build | |
id: build_step | |
run: | | |
python -m pip install --upgrade pip | |
pip install markdown | |
python 12DaysAlife.py | |
python makeAllEditions.py | |
- name: Deploy | |
if: github.ref == 'refs/heads/main' # It only runs on main branch (not in a Pull Request) | |
run: | | |
git add . | |
git commit -m 'Generated static html files' | |
git push -f origin $LOCAL_BRANCH_NAME:$HOSTING_BRANCH_NAME | |
- name: Teardown when the workflow failed | |
if: failure() && steps.build_step.outcome == 'failure' | |
run: | | |
git stash -u |