diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..18cf6d3 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Hugo Build and Deploy + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test_build: + name: Build Hugo Site + runs-on: ubuntu-latest + container: + image: klakegg/hugo:0.111.3-ext-alpine-ci + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check Hugo Version and Build + run: | + hugo version + hugo --minify + + deploy: + name: Deploy to Server + runs-on: ubuntu-latest + needs: test_build + if: github.ref == 'refs/heads/master' + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup SSH and Deploy + run: | + eval "$(ssh-agent -s)" + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + chmod 700 ~/.ssh + ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts + + ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" 'cd repo && git stash && git pull --force origin master && ./build.sh' + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_USER: ${{ secrets.SSH_USER }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_PORT: ${{ secrets.SSH_PORT }}