ericxliu-me/.gitea/workflows/publish.yaml

44 lines
1.3 KiB
YAML
Raw Normal View History

2024-06-15 05:04:36 +00:00
name: Hugo Publish CI
2024-06-11 18:46:54 +00:00
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
2024-06-12 04:49:06 +00:00
2024-06-11 18:46:54 +00:00
- name: Checkout code
2024-06-12 03:33:17 +00:00
uses: actions/checkout@v4
2024-06-12 03:44:12 +00:00
with:
2024-06-13 05:01:02 +00:00
persist-credentials: false
2024-06-12 03:44:12 +00:00
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
2024-06-11 18:46:54 +00:00
- name: Build site with Hugo
2024-06-12 03:44:12 +00:00
uses: peaceiris/actions-hugo@v3
2024-06-11 18:46:54 +00:00
with:
2024-06-13 02:27:58 +00:00
hugo-version: 'latest'
2024-06-12 03:46:09 +00:00
extended: true
2024-06-11 18:46:54 +00:00
2024-06-12 03:44:12 +00:00
- name: Build
run: hugo --minify
2024-06-11 18:46:54 +00:00
- name: Replace [commit] with short commit hash and hyperlink
run: |
SHORT_COMMIT=$(git rev-parse --short HEAD)
COMMIT_URL="https://git.ericxliu.me/eric/ericxliu-me/commit/$SHORT_COMMIT"
2024-09-16 20:08:55 +00:00
find ./public -type f -exec sed -i "s|\[commit\]|<a href=\"$COMMIT_URL\">\[$SHORT_COMMIT\]</a>|g" {} +
2024-06-12 03:44:12 +00:00
- name: Deploy
2024-06-12 03:55:45 +00:00
uses: peaceiris/actions-gh-pages@v4
2024-06-11 18:46:54 +00:00
with:
personal_token: ${{ secrets.GIT_PAGES_TOKEN }}
2024-06-13 02:33:02 +00:00
publish_dir: ./public
publish_branch: gitea-pages
- name: Reload Kubernetes pods
run: |
curl -X DELETE https://k8s.local:6443/api/v1/namespaces/hugo/pods/ --header "Authorization: Bearer ${{ secrets.HUGO_K8S_TOKEN }}" --insecure