From fe8b350645aba4199db83b73a70a89c519318b2a Mon Sep 17 00:00:00 2001 From: brookee Date: Thu, 29 Feb 2024 19:54:48 -0500 Subject: [PATCH] update --- .gitea/workflows/deploy.yaml | 16 ++++++++++++---- bin/test_static_page.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 bin/test_static_page.sh diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index e0a480a..7ee3e58 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -9,13 +9,21 @@ jobs: steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: recursive + - name: Add key + run: | + mkdir $HOME/.ssh && \ + echo "${{ secrets.SSH_PRIVATE_KEY }}" > $HOME/.ssh/id_rsa - name: Grab packages run: | apt-get update && \ - apt-get install -y jq rsync tar + apt-get install -y jq rsync tar wget && \ + wget https://github.com/gohugoio/hugo/releases/download/v0.123.4/hugo_0.123.4_linux-amd64.tar.gz && \ + tar -xzvf hugo_0.123.4_linux-amd64.tar.gz && \ + chmod +x hugo + - name: Run build task + run: ./hugo --minify --logLevel info + - name: Test static page + run: bash ${{ gitea.workspace }}/bin/test_static_page.sh - name: Deploy to Server uses: easingthemes/ssh-deploy@main env: diff --git a/bin/test_static_page.sh b/bin/test_static_page.sh new file mode 100644 index 0000000..14f4c97 --- /dev/null +++ b/bin/test_static_page.sh @@ -0,0 +1,26 @@ +#!/bin/bash +PORT=8080 +python3 -m http.server $PORT --directory public/ & + +SERVER_PID=$! + +# Give it a moment to start +sleep 2 + +# Check if the server is running +if ! ps -p $SERVER_PID > /dev/null; then + echo "HTTP server failed to start." + exit 1 +fi + +# Check HTTP status +status_code=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:$PORT) + +# Kill the http server +kill $SERVER_PID + +# Check if status code is 200 +if [ "$status_code" -ne 200 ]; then + echo "Website returned a non-200 status code: $status_code" + exit 1 +fi \ No newline at end of file