Github Pages #31360
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: Github Pages | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '1 */1 * * *' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup timezone | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: Asia/Hong_Kong | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Nested checkout branch | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
path: public | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.91.2' | |
- name: Build | |
run: hugo | |
- name: Check Changes | |
working-directory: ./public | |
run: | | |
CHANGES="$(git diff -U0 --word-diff|grep @@|wc -l)" | |
UPDATED="$(git diff -U0 --word-diff|grep updated|wc -l)" | |
if [ "$CHANGES" = "1" ] && [ "$UPDATED" = "1" ]; then | |
git checkout . | |
fi | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
full_commit_message: ${{ github.event.head_commit.message }} |