Remove mirroring and update website deployment
Some checks failed
Deploy Website / Deploy Hugo Site (push) Failing after 3s

- Removes the GitLab mirroring workflow.
- Replaces the existing website deployment workflow with a new Gitea Actions workflow.
- The new workflow uses SSH to deploy to a remote server.
- Adds a `build.sh` script to convert images to WebP format.
- The deployment workflow now clears Cloudflare cache.
- The old workflow used an external action for Cloudflare cache clearing.
This commit is contained in:
Roger Gonzalez 2025-05-15 20:51:26 -03:00
parent f396469ca7
commit bafe51c27b
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6
4 changed files with 57 additions and 56 deletions

View File

@ -0,0 +1,46 @@
name: Deploy Website
on:
push:
branches:
- master
workflow_dispatch:
jobs:
update:
name: Deploy Hugo Site
runs-on: ubuntu-latest
steps:
- name: Set up SSH and deploy site
run: |
echo "🔐 Setting up SSH"
eval "$(ssh-agent -s)"
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
chmod 700 ~/.ssh
ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
echo "🚀 Running remote build"
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "
cd repo &&
git stash &&
git pull --force origin master &&
./build.sh
"
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT }}
- name: Clear Cloudflare cache
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_TOKEN" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}

View File

@ -1,17 +0,0 @@
name: Mirroring
on: [push, delete]
jobs:
to_gitlab:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url:
git@gitlab.com:rogs/montevideo.restaurant.git
ssh_private_key:
${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

View File

@ -1,39 +0,0 @@
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push to master (including merged PRs)
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
update:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Update website.
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.ssh_host }}
username: ${{ secrets.ssh_user }}
key: ${{ secrets.ssh_key }}
passphrase: ${{ secrets.ssh_pass }}
port: ${{ secrets.ssh_port }}
script: |
cd repo
git stash
git pull --force origin master
rm -rf /var/www/montevideo.restaurant/*
hugo -s . -d /var/www/montevideo.restaurant/
- name: Clear Cloudflare cache.
uses: Cyb3r-Jak3/action-cloudflare-cache@main
with:
zone: ${{ secrets.CLOUDFLARE_ZONE }}
api_token: ${{ secrets.CLOUDFLARE_TOKEN }}

11
build.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
find ./ -type f -name '*.png' -not -path '*/.git/*' -exec sh -c 'cwebp -lossless "$1" -o "${1%.png}.webp"' _ {} \;
find ./ -type f -name '*.jpg' -not -path '*/.git/*' -exec sh -c 'cwebp -lossless "$1" -o "${1%.jpg}.webp"' _ {} \;
find ./ -type f -name '*.jpeg' -not -path '*/.git/*' -exec sh -c 'cwebp -lossless "$1" -o "${1%.jpeg}.webp"' _ {} \;
find . -type f -not -path '*/.git/*' -exec sed -i -e 's/\.png/\.webp/g' {} \;
find . -type f -not -path '*/.git/*' -exec sed -i -e 's/\.jpg/\.webp/g' {} \;
find . -type f -not -path '*/.git/*' -exec sed -i -e 's/\.jpeg/\.webp/g' {} \;
hugo -s . -d /var/www/montevideo.restaurant/ --minify --cacheDir $PWD/hugo-cache