Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

fix(manage-modules.sh): fix alpine container script shebang pointing … #42

fix(manage-modules.sh): fix alpine container script shebang pointing …

fix(manage-modules.sh): fix alpine container script shebang pointing … #42

Workflow file for this run

---
name: Maintenance
on:
push:
branches: [main]
workflow_dispatch:
inputs:
cleanup_images:
description: Clean up old Docker images
type: boolean
default: false
keep_amount:
description: Number of images to keep
required: false
default: '10'
remove_untagged:
description: Remove untagged images
type: boolean
default: false
manual_commit_ref:
description: SHA to compare for TODOs
required: false
manual_base_ref:
description: Optional earlier SHA for TODOs
required: false
schedule:
- cron: 0 3 1 * * # Monthly cleanup on 1st at 3 AM
- cron: 0 2 * * 0 # Weekly cleanup on Sundays at 2 AM
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
todos:
name: TODOs
runs-on: ubuntu-latest
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' &&
github.event.inputs.manual_commit_ref)
permissions:
contents: read
issues: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Convert
uses: alstr/[email protected]
with:
CLOSE_ISSUES: true
INSERT_ISSUE_URLS: true
AUTO_ASSIGN: true
IDENTIFIERS: |
[{"name": "TODO", "labels": ["enhancement"]}, {"name": "FIXME", "labels": ["bug"]}, {"name": "HACK", "labels": ["refactor", "hack"]}, {"name": "XXX", "labels": ["refactor", "hack"]}]
ESCAPE: true
IGNORE: |
.github/,node_modules/,dist/,build/,vendor/,data/,logs/
env:
MANUAL_COMMIT_REF: ${{ github.event.inputs.manual_commit_ref }}
MANUAL_BASE_REF: ${{ github.event.inputs.manual_base_ref }}
cleanup:
name: Cleanup
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch'
&& github.event.inputs.cleanup_images == 'true')
permissions:
packages: write
contents: read
strategy:
matrix:
service: [unrealircd, atheme, unrealircd-webpanel]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Registry Size Check ${{ matrix.service }}
id: registry_size
run: |
echo "Checking registry size for ${{ matrix.service }}..."
# Get package info to check size
PACKAGE_INFO=$(gh api user/packages/container/irc-atl-chat-${{ matrix.service }} 2>/dev/null || echo '{"size_in_bytes": 0}')
SIZE_BYTES=$(echo "$PACKAGE_INFO" | jq -r '.size_in_bytes // 0')
SIZE_GB=$(echo "scale=2; $SIZE_BYTES / 1024 / 1024 / 1024" | bc -l 2>/dev/null || echo "0")
{
echo "size_gb=$SIZE_GB"
echo "size_warning=$([ "$(echo "$SIZE_GB > 2" | bc -l)" = "1" ] && echo "true" || echo "false")"
} >> "$GITHUB_OUTPUT"
echo "Registry size for ${{ matrix.service }}: ${SIZE_GB}GB"
# Alert if size is too large
if (( $(echo "$SIZE_GB > 2" | bc -l) )); then
echo "⚠️ Registry size for ${{ matrix.service }} exceeds 2GB: ${SIZE_GB}GB"
else
echo "✅ Registry size for ${{ matrix.service }} is acceptable: ${SIZE_GB}GB"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean Old Images ${{ matrix.service }}
uses: actions/delete-package-versions@v5
with:
package-name: irc-atl-chat-${{ matrix.service }}
package-type: container
min-versions-to-keep: ${{ github.event.inputs.keep_amount || '15' }}
delete-only-untagged-versions: ${{ github.event.inputs.remove_untagged || 'true' }}
- name: Clean Build Cache Images ${{ matrix.service }}
run: |
echo "Cleaning up build cache images for ${{ matrix.service }}..."
# Delete build cache images older than 30 days
gh api user/packages/container/irc-atl-chat-${{ matrix.service }}/versions | \
jq -r '.[] | select(.name | contains("buildcache")) | select(.created_at < "'"$(date -d '30 days ago' -Iseconds)"'") | .id' | \
xargs -I {} gh api -X DELETE user/packages/container/irc-atl-chat-${{ matrix.service }}/versions/{} || echo "No build cache images to clean for ${{ matrix.service }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Registry Cleanup Summary ${{ matrix.service }}
run: |
{
echo "## 🧹 Registry Cleanup Summary - ${{ matrix.service }}"
echo "- **Registry Size**: ${{ steps.registry_size.outputs.size_gb }}GB"
echo "- **Cleanup Policy**: Keep 15 versions, remove untagged"
echo "- **Build Cache**: Cleaned images older than 30 days"
if [ "${{ steps.registry_size.outputs.size_warning }}" = "true" ]; then
echo "- **⚠️ Warning**: Registry size exceeds 2GB"
else
echo "- **✅ Status**: Registry size is acceptable"
fi
} >> "$GITHUB_STEP_SUMMARY"
health:
name: Health Check
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
permissions:
contents: read
issues: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Repository Health Summary
run: |
{
echo "## 📊 Repository Health Check"
echo "**Date**: $(date)"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Check Large Files
run: |
{
echo "### 📁 Large Files Check"
echo "Checking for files larger than 50MB..."
} >> "$GITHUB_STEP_SUMMARY"
LARGE_FILES=$(find . -type f -size +50M -not -path "./.git/*" 2>/dev/null || echo "")
if [ -n "$LARGE_FILES" ]; then
{
echo "⚠️ **Large files found:**"
echo '```'
echo "$LARGE_FILES"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
else
echo "✅ **No large files found**" >> "$GITHUB_STEP_SUMMARY"
fi
echo "" >> "$GITHUB_STEP_SUMMARY"
- name: Check Docker Compose Configuration
run: |
{
echo "### 🐳 Docker Compose Health Check"
echo "Validating compose configuration with DCLint..."
} >> "$GITHUB_STEP_SUMMARY"
# Run DCLint to check Docker Compose configuration
if docker run --rm -v "$(pwd):/workspace" -w /workspace \
docker.io/dockercomposelinter/dclint:latest . --formatter json 2>/dev/null; then
echo "✅ **Docker Compose configuration is valid**" >> "$GITHUB_STEP_SUMMARY"
else
echo "❌ **Docker Compose configuration has issues**" >> "$GITHUB_STEP_SUMMARY"
fi
echo "" >> "$GITHUB_STEP_SUMMARY"
- name: Check Containerfile Health
run: |
{
echo "### 📦 Containerfile Health Check"
echo "Checking Containerfiles for common issues..."
} >> "$GITHUB_STEP_SUMMARY"
for containerfile in $(find . -name "Containerfile" -o -name "Dockerfile"); do
echo "**Checking**: $containerfile" >> "$GITHUB_STEP_SUMMARY"
# Check for common security issues
if grep -q "RUN.*apt-get.*update.*&&.*apt-get.*install" "$containerfile"; then
echo "✅ Uses combined RUN commands for apt-get" >> "$GITHUB_STEP_SUMMARY"
fi
if grep -q "USER.*root" "$containerfile"; then
echo "⚠️ Uses root user - consider non-root user" >> "$GITHUB_STEP_SUMMARY"
fi
if grep -q "EXPOSE.*80\|EXPOSE.*443\|EXPOSE.*22" "$containerfile"; then
echo "✅ Properly exposes common ports" >> "$GITHUB_STEP_SUMMARY"
fi
done
echo "" >> "$GITHUB_STEP_SUMMARY"
- name: Check Repository Size
run: |
{
echo "### 💾 Repository Size Analysis"
REPO_SIZE=$(du -sh . 2>/dev/null | cut -f1 || echo "Unknown")
echo "**Repository Size**: $REPO_SIZE"
# Check .git size
GIT_SIZE=$(du -sh .git 2>/dev/null | cut -f1 || echo "Unknown")
echo "**Git History Size**: $GIT_SIZE"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Check Stale Branches
run: |
{
echo "### 🌿 Branch Analysis"
echo "**Recent branches:**"
echo '```'
git branch -r --sort=-committerdate | head -10 2>/dev/null || echo "Could not check branches"
echo '```'
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Check Registry Health
run: |
{
echo "### 🐳 Container Registry Health"
if command -v gh >/dev/null 2>&1; then
TOTAL_SIZE=0
TOTAL_VERSIONS=0
for service in unrealircd atheme unrealircd-webpanel; do
# Get package info
PACKAGE_INFO=$(gh api user/packages/container/irc-atl-chat-$service 2>/dev/null || echo '{"size_in_bytes": 0, "version_count": 0}')
SIZE_BYTES=$(echo "$PACKAGE_INFO" | jq -r '.size_in_bytes // 0')
VERSION_COUNT=$(echo "$PACKAGE_INFO" | jq -r '.version_count // 0')
SIZE_GB=$(echo "scale=2; $SIZE_BYTES / 1024 / 1024 / 1024" | bc -l 2>/dev/null || echo "0")
echo "**$service**: ${SIZE_GB}GB, $VERSION_COUNT versions"
TOTAL_SIZE=$(echo "$TOTAL_SIZE + $SIZE_GB" | bc -l)
TOTAL_VERSIONS=$((TOTAL_VERSIONS + VERSION_COUNT))
done
echo "**Total Registry Size**: ${TOTAL_SIZE}GB"
echo "**Total Version Count**: $TOTAL_VERSIONS"
if (( $(echo "$TOTAL_SIZE > 10" | bc -l) )); then
echo "⚠️ **Warning**: Total registry size exceeds 10GB"
else
echo "✅ **Status**: Registry size is acceptable"
fi
else
echo "⚠️ **GitHub CLI not available for registry check**"
fi
echo ""
} >> "$GITHUB_STEP_SUMMARY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Recent Activity
run: |-
{
echo "### 📈 Recent Activity"
echo "**Recent commits:**"
echo '```'
git log --oneline --since="1 week ago" | head -10 2>/dev/null || echo "Could not check recent commits"
echo '```'
echo ""
} >> "$GITHUB_STEP_SUMMARY"
- name: Check SSL Certificate Health
run: |
{
echo "### 🔒 SSL Certificate Health Check"
echo "Checking for SSL-related files and configurations..."
if [ -f "scripts/ssl-manager.sh" ]; then
echo "✅ SSL management script exists"
else
echo "⚠️ SSL management script not found"
fi
if [ -d "data/letsencrypt" ]; then
echo "✅ Let's Encrypt data directory exists"
CERT_COUNT=$(find data/letsencrypt -name "*.pem" 2>/dev/null | wc -l)
echo "**Certificate files found**: $CERT_COUNT"
else
echo "⚠️ Let's Encrypt data directory not found"
fi
if [ -f "cloudflare-credentials.ini.template" ]; then
echo "✅ Cloudflare credentials template exists"
else
echo "⚠️ Cloudflare credentials template not found"
fi
echo ""
} >> "$GITHUB_STEP_SUMMARY"