diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..b16eb53 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Deploying Website +run-name: ${{ gitea.actor }} is testing out Deploying Website +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Updating apt get + run: apt update && apt upgrade -y + + - name: Install rsync + run: apt install rsync -y + + - name: Install Hugo + run: apt install hugo -y + + - name: Clone the repository + uses: actions/checkout@v4 + + - name: Create the public directory + run: mkdir /public /hugo_cache + + - name: Build the website + run: hugo --minify + + - name: Add host key to known_hosts + run: | + mkdir -p ~/.ssh + echo "${{ secrets.RUNNER_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -p ${{ secrets.SERVER_PORT }} -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts + + - name: Test SSH connection + run: ssh -v -p ${{ secrets.SERVER_PORT }} -i ~/.ssh/id_rsa ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} 'echo "SSH connection successful"' + + - name: Deploy to server + run: | + rsync -avz -e 'ssh -p ${{ secrets.SERVER_PORT }}' --delete public/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/var/www/todo.hstr.fr