Actions update 10
Some checks failed
Publish Website / publish (push) Failing after 2s

This commit is contained in:
Akshay
2025-07-19 21:32:07 -04:00
parent 305dd24b68
commit 26591de2c2

View File

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