This commit is contained in:
parent
f08363cf71
commit
a62b17e4e9
2 changed files with 36 additions and 5 deletions
|
@ -9,17 +9,22 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- 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 wget && \
|
||||
wget https://github.com/gohugoio/hugo/releases/download/v0.123.4/hugo_extended_0.123.4_linux-amd64.tar.gz && \
|
||||
tar -xzvf hugo_extended_0.123.4_linux-amd64.tar.gz && \
|
||||
chmod +x hugo
|
||||
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
|
||||
# run: rsync -avz --delete public/ ${{ vars.REMOTE_USER }}@${{ vars.REMOTE_HOST }}:${{ vars.REMOTE_TARGET }}
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
|
@ -27,4 +32,4 @@ jobs:
|
|||
SOURCE: "public/"
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||
TARGET: ${{ secrets.REMOTE_TARGET }}
|
||||
TARGET: ${{ secrets.REMOTE_TARGET }}
|
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…
Add table
Reference in a new issue