Skip to content

generate

generate #272

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: build hugo
# Controls when the workflow will run
on:
workflow_dispatch:
repository_dispatch:
types: [generate]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
#https://gohugo.io/hosting-and-deployment/hosting-on-github/
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
repository: deletefromuser/hugo-source
token: ${{ secrets.PAT }}
- name: Setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.68.3"
- name: build hugo & commit & push
run: |
git config --global user.name github-actions[bot]
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
cd public
git checkout main
cd ..
hugo -t zen -b "https://deletefromuser.github.io/"
cd public
git add .
msg="rebuilding site $(TZ='Asia/Shanghai' date '+%Y-%m-%dT%H:%M:%S+08:00')"
if [ -n "$*" ]; then
msg="$*"
fi
if ! git status | grep -q 'nothing to commit, working tree clean'; then
git commit -m "$msg"
git checkout self-host
cd ..
hugo -t zen
cd public
git add .
git commit -m "$msg"
git push --all
curl -k ${{ secrets.SELF_HOST_URL }}
fi
# - name: notify profile readme.md to regenerate
# run: |
# curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.PAT }}" https://api.github.com/repos/deletefromuser/deletefromuser/dispatches -d '{"event_type":"generate"}'