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

45 lines
1.2 KiB
YAML
Raw Normal View History

2024-06-11 18:48:20 +00:00
name: CI Hugo Publish
2024-06-11 18:46:54 +00:00
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
2024-06-12 03:33:17 +00:00
uses: actions/checkout@v4
2024-06-12 03:44:12 +00:00
with:
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: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H git.ericxliu.me >> ~/.ssh/known_hosts
- 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-12 03:44:12 +00:00
hugo-version: '0.119.0'
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
2024-06-12 03:44:12 +00:00
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
2024-06-12 03:48:31 +00:00
if: ${{ github.ref == 'refs/heads/master' }}
2024-06-11 18:46:54 +00:00
with:
2024-06-12 03:44:12 +00:00
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
2024-06-11 18:46:54 +00:00
- name: Delete Kubernetes pod
run: |
curl -X DELETE ${{ secrets.APISERVER }}/api/v1/namespaces/Hugo/pods/ \
--header "Authorization: Bearer ${{ secrets.TOKEN }}" --insecure