ericxliu-me/.gitea/workflows/publish.yaml
eric Liu dc4dbb8343
Some checks failed
CI Hugo Publish / build-and-deploy (push) Failing after 5s
Update .gitea/workflows/publish.yaml
2024-06-12 03:33:17 +00:00

49 lines
1.3 KiB
YAML

name: CI Hugo Publish
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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.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