generated from coredotbin/template-ansible-project
Tweak workflow
Some checks failed
Build, test, and deploy Hugo site / deploy-prod (push) Failing after 20s
Some checks failed
Build, test, and deploy Hugo site / deploy-prod (push) Failing after 20s
This commit is contained in:
parent
1e88c31020
commit
fda81ac9fa
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
name: Build, and deploy Hugo site
|
name: Build, test, and deploy Hugo site
|
||||||
run-name: ${{ gitea.actor }} is building, and deploying the static page
|
run-name: ${{ gitea.actor }} is building, testing, and deploying the static page
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@ -11,8 +11,6 @@ jobs:
|
|||||||
deploy-prod:
|
deploy-prod:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -30,11 +28,12 @@ jobs:
|
|||||||
run: tar -xf /tmp/hugo/* -C ${{ gitea.workspace }}/bin
|
run: tar -xf /tmp/hugo/* -C ${{ gitea.workspace }}/bin
|
||||||
- name: Build the static webpage
|
- name: Build the static webpage
|
||||||
run: ${{ gitea.workspace }}/bin/hugo --minify
|
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: |
|
run: |
|
||||||
echo "${{ secrets.ACT_RUNNER_KEY }}" > /tmp/act_runner_key
|
echo "${{ secrets.ACT_RUNNER_KEY }}" > /tmp/act_runner_key
|
||||||
chmod 600 /tmp/act_runner_key
|
chmod 600 /tmp/act_runner_key
|
||||||
- name: rsync public directory
|
- name: rsync public directory
|
||||||
run: |
|
run: |
|
||||||
rsync -avz --delete -e "ssh -i /tmp/act_runner_key -o StrictHostKeyChecking=no" ${{ gitea.workspace }}/public/* act_runner@whatnow.site:/var/media/nginx/
|
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
26
bin/test_static_page.sh
Normal 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
|
Loading…
x
Reference in New Issue
Block a user