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

53 lines
1.5 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
uses: actions/checkout@v2
with:
submodules: recursive
ssh-key: ${{ secrets.SSH_KEY }}
2024-06-12 03:23:09 +00:00
github-server-url: git.ericxliu.me
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: Clone gitea-pages branch
run: |
git clone --branch gitea-pages git@git.ericxliu.me:eric/ericxliu-me.git output
find output -mindepth 1 -not -regex "^.*\/.git\/.*" -delete
- name: Build site with Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.97.0'
extended: true
- name: Add commit hash to index.html
run: |
sed -i 's/\[commit\]/\[${{ github.sha::0:7 }}\]/g' output/index.html
- name: Push changes to gitea-pages branch
uses: ad-m/github-push-action@v0.6.0
with:
branch: gitea-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
message: "Drone build ${{ github.sha::0:7 }}"
- name: Delete Kubernetes pod
run: |
curl -X DELETE ${{ secrets.APISERVER }}/api/v1/namespaces/Hugo/pods/ \
--header "Authorization: Bearer ${{ secrets.TOKEN }}" --insecure