Tweak workflow
Some checks failed
Build, test, and deploy Hugo site / deploy-prod (push) Failing after 20s

This commit is contained in:
Corbin 2025-03-23 22:27:50 -04:00
parent 1e88c31020
commit fda81ac9fa
Signed by: coredotbin
GPG Key ID: B03E030E4322E9D5
2 changed files with 31 additions and 6 deletions

View File

@ -1,7 +1,7 @@
---
name: Build, and deploy Hugo site
run-name: ${{ gitea.actor }} is building, and deploying the static page
name: Build, test, and deploy Hugo site
run-name: ${{ gitea.actor }} is building, testing, and deploying the static page
on:
push:
branches:
@ -11,8 +11,6 @@ jobs:
deploy-prod:
runs-on: ubuntu-latest
steps:
- run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
with:
@ -30,11 +28,12 @@ jobs:
run: tar -xf /tmp/hugo/* -C ${{ gitea.workspace }}/bin
- name: Build the static webpage
run: ${{ gitea.workspace }}/bin/hugo --minify
- name: Create private key
- name: Test static page
run: bash ${{ gitea.workspace}}/bin/test_static_page.sh
- name: Copy private key
run: |
echo "${{ secrets.ACT_RUNNER_KEY }}" > /tmp/act_runner_key
chmod 600 /tmp/act_runner_key
- name: rsync public directory
run: |
rsync -avz --delete -e "ssh -i /tmp/act_runner_key -o StrictHostKeyChecking=no" ${{ gitea.workspace }}/public/* act_runner@whatnow.site:/var/media/nginx/
- run: echo "This job's status is ${{ job.status }}."

26
bin/test_static_page.sh Normal file
View File

@ -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