deploy website #121
This file contains hidden or 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 website | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - master | |
| paths: | |
| - questions/*.md | |
| - img/** | |
| watch: | |
| types: [started] | |
| jobs: | |
| compile-n-deploy: | |
| name: Deploy website | |
| runs-on: ubuntu-latest | |
| if: github.actor == github.event.repository.owner.login | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 2 | |
| submodules: 'recursive' | |
| - name: "Generate content" | |
| shell: bash | |
| run: | | |
| source .env | |
| python3.7 website/builder.py | |
| - name: "Prepare gh-pages branch" | |
| shell: bash | |
| run: | | |
| mkdir website/public | |
| git worktree prune | |
| rm -rf .git/worktrees/public | |
| git worktree add -B gh-pages website/public | |
| rm -rf website/public/* | |
| rm -rf website/public/{.github,.gitignore,.gitmodules,.env} | |
| - name: "Install hudo" | |
| shell: bash | |
| run: | | |
| wget -O /tmp/hugo.deb "https://github.com/gohugoio/hugo/releases/download/v0.71.1/hugo_0.71.1_Linux-64bit.deb" | |
| sudo dpkg -i /tmp/hugo.deb | |
| - name: "Build static pages" | |
| shell: bash | |
| run: | | |
| hugo -s website/hugo | |
| - name: "Commit static pages to gh-pages" | |
| shell: bash | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| cd website/public | |
| git add --all | |
| git commit -m "Publish to gh-pages" | |
| - name: "Push changes" | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: gh-pages | |
| directory: ./website/public | |
| force: true |