name: CI Hugo Publish 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