From 5c9e050b970c5bd5f1f6e9c034933838196f1702 Mon Sep 17 00:00:00 2001 From: eric Liu Date: Tue, 11 Jun 2024 18:46:54 +0000 Subject: [PATCH] Add .gitea/workflows/publish.yaml --- .gitea/workflows/publish.yaml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .gitea/workflows/publish.yaml diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..8b8b2f9 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,52 @@ +name: CI + +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 }} + + - 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 \ No newline at end of file