Files
website/.gitea/workflows/publish.yml
Akshay 26591de2c2
Some checks failed
Publish Website / publish (push) Failing after 2s
Actions update 10
2025-07-19 21:32:07 -04:00

83 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# .gitea/workflows/publish.yml
name: Publish Website
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
push:
branches: [ main ] # <- typo fixed (“braches” → “branches”)
jobs:
publish:
runs-on: ubuntu-latest
steps:
# ------------------------------------------------------------
# 0. Detect the hostside IP that Docker containers use
# ------------------------------------------------------------
- name: Detect Gitea host IP (inside runner)
id: detect_host
shell: bash
run: |
HOST_IP=$(ip route | awk '/default/ {print $3}')
echo "GITEA_HOST=$HOST_IP" >> "$GITHUB_ENV"
echo "Detected host IP: $HOST_IP"
# ------------------------------------------------------------
# 1. Checkout the website repository (your app code)
# ------------------------------------------------------------
- name: Checkout website repo
uses: actions/checkout@v4 # avoids manual clone
with:
repository: lepton/website # full owner/repo path
fetch-depth: 1
# ------------------------------------------------------------
# 2. Start an SSH agent and load the private key from secrets
# ------------------------------------------------------------
- name: Set up SSH agent
env:
SSH_KEY: ${{ secrets.ACCESS_KEY }} # your private key
shell: bash
run: |
eval "$(ssh-agent -s)"
echo "$SSH_KEY" | tr -d '\r' | ssh-add - >/dev/null
ssh-add -l
# ------------------------------------------------------------
# 3. Trust the Gitea host key (port 222)
# ------------------------------------------------------------
- name: Trust Gitea host key
shell: bash
run: |
mkdir -p ~/.ssh
ssh-keyscan -H -p 222 "$GITEA_HOST" 2>/dev/null >> ~/.ssh/known_hosts
# ------------------------------------------------------------
# 4. Clone the template repo via SSH (uses detected IP + port 222)
# ------------------------------------------------------------
- name: Clone template repo
shell: bash
run: |
git clone --depth 1 \
"ssh://git@$GITEA_HOST:222/lepton/app_templates" /tmp/template
# ------------------------------------------------------------
# 5. Copy Docker artefacts into workspace root
# ------------------------------------------------------------
- name: Copy Docker configuration
shell: bash
run: |
cp /tmp/template/web/docker-compose.yml .
cp /tmp/template/web/Dockerfile .
# ------------------------------------------------------------
# 6. Stop any old stack, rebuild, and run the new one
# ------------------------------------------------------------
- name: Stop existing stack (ignore if none)
shell: bash
run: docker compose down --remove-orphans || true
- name: Rebuild & deploy
shell: bash
run: docker compose up -d --build