Switch from GitHub Actions to self-hosted Gitea CI/CD
Some checks failed
Deploy hatch.surf / build-and-deploy (push) Failing after 1m37s

- Removed .github/workflows/deploy.yml (GitHub Actions)
- Added .gitea/workflows/deploy.yml (Gitea Actions)
- Added setup-gitea.sh for installing Gitea
- Added configure-gitea.sh for configuring Gitea
- Self-hosted Git + CI/CD on local server
- GitHub org only for final open-source projects

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Chris Anderson 2026-06-24 09:57:20 +02:00
parent 17eee790c4
commit 8bce1cb670
4 changed files with 145 additions and 63 deletions

View File

@ -0,0 +1,38 @@
name: Deploy hatch.surf
on:
push:
branches: [main]
workflow_dispatch:
env:
IMAGE_NAME: hatch-web
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} .
docker tag ${{ env.IMAGE_NAME }}:${{ github.sha }} ${{ env.IMAGE_NAME }}:latest
- name: Deploy to server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /home/nara/repos/hatch-surf
git pull origin main
docker compose build
docker compose up -d --remove-orphans
docker system prune -f

View File

@ -1,63 +0,0 @@
name: Deploy hatch.surf
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/hatch-web
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=ref,event=branch
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Deploy to server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /home/nara/repos/hatch-surf
git pull origin main
docker compose pull
docker compose up -d --remove-orphans
docker system prune -f

53
configure-gitea.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
# Configure Gitea for El Foundation
# Run after initial Gitea setup
set -e
GITEA_URL="http://localhost:3000"
GITEA_TOKEN="${GITEA_TOKEN:-your-admin-token}"
echo "=== Configuring Gitea for El Foundation ==="
# Create organization
echo "Creating El Foundation organization..."
curl -X POST "$GITEA_URL/api/v1/orgs" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"username": "el-foundation",
"full_name": "El Foundation",
"description": "El Foundation - Open Source Projects",
"website": "",
"location": "",
"visibility": "public"
}'
# Create hatch-surf repository
echo "Creating hatch-surf repository..."
curl -X POST "$GITEA_URL/api/v1/orgs/el-foundation/repos" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "hatch-surf",
"description": "Hatch.surf web application",
"private": false,
"auto_init": false,
"default_branch": "main"
}'
# Add remote to local repo
echo "Adding Gitea remote to local repo..."
cd /home/nara/apps/web
git remote add origin http://localhost:3000/el-foundation/hatch-surf.git
git push -u origin main
echo ""
echo "=== Configuration Complete ==="
echo "Repository: $GITEA_URL/el-foundation/hatch-surf"
echo ""
echo "To enable Gitea Actions (CI/CD):"
echo "1. Go to repository Settings > Actions"
echo "2. Enable Actions"
echo "3. Add secrets: SERVER_HOST, SERVER_USER, SERVER_SSH_KEY"
echo "4. Push to main branch to trigger deployment"

54
setup-gitea.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
# Gitea Setup Script for El Foundation
# Self-hosted Git + CI/CD
set -e
GITEA_VERSION="1.22"
GITEA_PORT="3000"
GITEA_DATA="/var/lib/gitea"
GITEA_CONFIG="/etc/gitea"
echo "=== Setting up Gitea for El Foundation ==="
# Install Gitea
echo "Installing Gitea..."
wget -O /usr/local/bin/gitea https://dl.gitea.com/gitea/${GITEA_VERSION}.0/gitea-${GITEA_VERSION}.0-linux-amd64
chmod +x /usr/local/bin/gitea
# Create directories
sudo mkdir -p $GITEA_DATA $GITEA_CONFIG
sudo chown -R nara:nara $GITEA_DATA $GITEA_CONFIG
# Create systemd service
cat > /tmp/gitea.service << 'EOF'
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
[Service]
Type=simple
User=nara
Group=nara
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=nara HOME=/home/nara GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
EOF
sudo mv /tmp/gitea.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
echo "Gitea installed and started on port $GITEA_PORT"
echo "Access at http://localhost:$GITEA_PORT"
echo ""
echo "Next steps:"
echo "1. Open http://localhost:$GITEA_PORT in browser"
echo "2. Complete initial setup"
echo "3. Create admin account"
echo "4. Run: ./configure-gitea.sh"