Fix DNS resolution: use actual Forgejo hostname and add IP fallback

This commit is contained in:
robojerk 2025-08-10 08:38:22 -07:00
parent 24276437d3
commit 8158c6d85b
2 changed files with 126 additions and 69 deletions

View file

@ -1,19 +1,7 @@
name: Build deb-bootupd Artifacts
# ⚠️ IMPORTANT: Each repository needs its own ACCESS_TOKEN secret!
#
# To set up this workflow in a new repository:
# 1. Go to repository settings: https://git.raines.xyz/OWNER/REPO/settings
# 2. Find "Secrets" or "Repository secrets" section
# 3. Add new secret:
# - Name: ACCESS_TOKEN
# - Value: Your Personal Access Token with repo and write:packages permissions
# 4. The token needs these scopes:
# - repo (Full control of private repositories)
# - write:packages (Write packages)
# - read:packages (Read packages)
#
# This workflow will fail with "ACCESS_TOKEN is not set" if the secret is missing.
# Comprehensive workflow for building and uploading deb-bootupd artifacts
# Based on patterns from: https://domaindrivenarchitecture.org/pages/dda-pallet/
on:
push:
@ -32,65 +20,105 @@ jobs:
env:
FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }}
FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }}
# Use actual IP if available, fallback to hostname
FORGEJO_IP: ${{ secrets.FORGEJO_IP || '' }}
container:
image: 'rust:1.89'
image: 'rust:1.89-slim-trixie'
options: |
--dns=8.8.8.8
--dns=8.8.4.4
--add-host=git.raines.xyz:host-gateway
--add-host=forgejo:host-gateway
steps:
- name: Setup build environment
- name: Checkout code and setup environment
run: |
# Update package lists
apt update -y
# Install required system packages
apt install -y libssl-dev libsystemd-dev file pkg-config build-essential zip nodejs npm
apt install -y git curl pkg-config libssl-dev libsystemd-dev build-essential file zip nodejs npm
# Install required Rust components
echo "Installing Rust components..."
rustup component add clippy
rustup component add rustfmt
rustup component add rust-src
rustup component add rust-analysis
rustup component add rust-src # For better error messages
rustup component add rust-analysis # For IDE support
# Verify Rust installation
rustc --version
cargo --version
rustup component list | grep -E "(clippy|rustfmt|rust-src|rust-analysis)"
# Test DNS resolution
echo "Testing DNS resolution..."
echo "Testing forgejo hostname resolution:"
nslookup forgejo || echo "forgejo hostname not resolved"
echo "Testing explicit Forgejo host resolution:"
nslookup $FORGEJO_HOST || echo "Explicit hostname not resolved"
echo "Testing external DNS:"
nslookup google.com || echo "External DNS not working"
echo "Testing IP connectivity:"
ping -c 3 8.8.8.8 || echo "IP connectivity failed"
# Show network configuration
echo "Network configuration:"
cat /etc/resolv.conf
ip route show
# Enhanced network diagnostics
echo "=== NETWORK DIAGNOSTICS ==="
echo "Container hostname: $(hostname)"
echo "Container IP: $(hostname -i)"
- name: Checkout repository manually
run: |
# Clone the repository manually instead of using actions/checkout
echo "Container DNS: $(cat /etc/resolv.conf)"
echo "Container routing:"
ip route show
echo "=== HOSTNAME RESOLUTION TESTS ==="
echo "Testing forgejo hostname:"
nslookup forgejo || echo "❌ forgejo hostname not resolved"
echo "Testing git.raines.xyz hostname:"
nslookup git.raines.xyz || echo "❌ git.raines.xyz hostname not resolved"
echo "Testing explicit FORGEJO_HOST ($FORGEJO_HOST):"
nslookup $FORGEJO_HOST || echo "❌ FORGEJO_HOST not resolved"
echo "Testing external DNS (google.com):"
nslookup google.com || echo "❌ External DNS not working"
echo "=== IP CONNECTIVITY TESTS ==="
echo "Testing Google DNS (8.8.8.8):"
ping -c 3 8.8.8.8 || echo "❌ Google DNS ping failed"
echo "Testing Cloudflare DNS (1.1.1.1):"
ping -c 3 1.1.1.1 || echo "❌ Cloudflare DNS ping failed"
# Try to resolve Forgejo server IP if not provided
if [ -z "$FORGEJO_IP" ]; then
echo "=== RESOLVING FORGEJO SERVER IP ==="
FORGEJO_IP=$(nslookup $FORGEJO_HOST | grep -A1 "Name:" | grep "Address:" | awk '{print $2}' | head -1)
if [ -n "$FORGEJO_IP" ]; then
echo "✅ Resolved $FORGEJO_HOST to IP: $FORGEJO_IP"
echo "FORGEJO_IP=$FORGEJO_IP" >> $GITHUB_ENV
else
echo "❌ Could not resolve $FORGEJO_HOST to IP"
fi
fi
# Test direct IP connectivity if available
if [ -n "$FORGEJO_IP" ]; then
echo "Testing direct IP connectivity to $FORGEJO_IP:"
ping -c 3 $FORGEJO_IP || echo "❌ Direct IP ping failed"
fi
echo "=== RUST ENVIRONMENT ==="
echo "Available Rust components:"
rustup component list --installed
echo "✅ Using pre-installed Rust from official image:"
rustc --version
cargo --version
# Clone repository
git clone https://git.raines.xyz/robojerk/deb-bootupd.git /tmp/deb-bootupd
cd /tmp/deb-bootupd
# Show repository info
echo "Repository: $(git remote get-url origin)"
echo "Branch: $(git branch --show-current)"
echo "Commit: $(git rev-parse --short HEAD)"
echo "Date: $(git log -1 --format=%cd)"
# Verify Rust version meets requirements (need 1.84.1+)
RUST_VERSION=$(rustc --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1)
echo "Rust version: $RUST_VERSION"
if [ "$(printf '%s\n' "1.84.1" "$RUST_VERSION" | sort -V | head -n1)" != "1.84.1" ]; then
echo "❌ Rust version $RUST_VERSION is too old, need 1.84.1+"
exit 1
else
echo "✅ Rust version $RUST_VERSION meets requirement (1.84.1+)"
fi
# Rust environment is already set up in the container
echo "Rust environment ready:"
echo "RUSTUP_HOME: $RUSTUP_HOME"
echo "CARGO_HOME: $CARGO_HOME"
echo "PATH includes: $PATH"
- name: Build Rust project
run: |

View file

@ -16,11 +16,14 @@ jobs:
env:
FORGEJO_URL: ${{ secrets.FORGEJO_URL || 'https://git.raines.xyz' }}
FORGEJO_HOST: ${{ secrets.FORGEJO_HOST || 'git.raines.xyz' }}
# Use actual IP if available, fallback to hostname
FORGEJO_IP: ${{ secrets.FORGEJO_IP || '' }}
container:
image: 'rust:1.89-slim-trixie'
options: |
--dns=8.8.8.8
--dns=8.8.4.4
--add-host=git.raines.xyz:host-gateway
--add-host=forgejo:host-gateway
steps:
- name: Checkout code and setup environment
@ -35,27 +38,53 @@ jobs:
rustup component add rust-src # For better error messages
rustup component add rust-analysis # For IDE support
# Test DNS resolution
echo "Testing DNS resolution..."
echo "Testing forgejo hostname resolution:"
nslookup forgejo || echo "forgejo hostname not resolved"
echo "Testing explicit Forgejo host resolution:"
nslookup $FORGEJO_HOST || echo "Explicit hostname not resolved"
echo "Testing external DNS:"
nslookup google.com || echo "External DNS not working"
echo "Testing IP connectivity:"
ping -c 3 8.8.8.8 || echo "IP connectivity failed"
# Show network configuration
echo "Network configuration:"
cat /etc/resolv.conf
ip route show
# Enhanced network diagnostics
echo "=== NETWORK DIAGNOSTICS ==="
echo "Container hostname: $(hostname)"
echo "Container IP: $(hostname -i)"
echo "Container DNS: $(cat /etc/resolv.conf)"
echo "Container routing:"
ip route show
echo "=== HOSTNAME RESOLUTION TESTS ==="
echo "Testing forgejo hostname:"
nslookup forgejo || echo "❌ forgejo hostname not resolved"
echo "Testing git.raines.xyz hostname:"
nslookup git.raines.xyz || echo "❌ git.raines.xyz hostname not resolved"
echo "Testing explicit FORGEJO_HOST ($FORGEJO_HOST):"
nslookup $FORGEJO_HOST || echo "❌ FORGEJO_HOST not resolved"
echo "Testing external DNS (google.com):"
nslookup google.com || echo "❌ External DNS not working"
echo "=== IP CONNECTIVITY TESTS ==="
echo "Testing Google DNS (8.8.8.8):"
ping -c 3 8.8.8.8 || echo "❌ Google DNS ping failed"
echo "Testing Cloudflare DNS (1.1.1.1):"
ping -c 3 1.1.1.1 || echo "❌ Cloudflare DNS ping failed"
# Try to resolve Forgejo server IP if not provided
if [ -z "$FORGEJO_IP" ]; then
echo "=== RESOLVING FORGEJO SERVER IP ==="
FORGEJO_IP=$(nslookup $FORGEJO_HOST | grep -A1 "Name:" | grep "Address:" | awk '{print $2}' | head -1)
if [ -n "$FORGEJO_IP" ]; then
echo "✅ Resolved $FORGEJO_HOST to IP: $FORGEJO_IP"
echo "FORGEJO_IP=$FORGEJO_IP" >> $GITHUB_ENV
else
echo "❌ Could not resolve $FORGEJO_HOST to IP"
fi
fi
# Test direct IP connectivity if available
if [ -n "$FORGEJO_IP" ]; then
echo "Testing direct IP connectivity to $FORGEJO_IP:"
ping -c 3 $FORGEJO_IP || echo "❌ Direct IP ping failed"
fi
echo "=== RUST ENVIRONMENT ==="
echo "Available Rust components:"
rustup component list --installed
echo "✅ Using pre-installed Rust from official image:"