Files
lunafreya-lva/.gitea/workflows/compose-services-readme.yml
T
2025-10-06 07:36:26 -04:00

109 lines
3.0 KiB
YAML

name: List of Services README Generation
on:
schedule:
- cron: 30 */2 * * *
workflow_dispatch:
jobs:
readme-services:
name: Generate Services List
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
ref: 'main'
submodules: true
- name: Install yq
uses: dcarbone/install-yq-action@4075b4dca348d74bd83f2bf82d30f25d7c54539b # v1.3.1
- name: Find docker-compose YAML files
id: find-compose-files
run: |
COMPOSE_FILES=$(find . -type f -name "docker-compose*.yml" \
-a ! -name "*windows*" \
-a ! -name "*gui*" \
-a ! -name "*macos*" \
-a ! -name "*hivemind*" \
-a ! -name "*server*" \
| sort)
echo "Found Compose files:"
echo "$COMPOSE_FILES"
{
echo "compose_files<<EOF"
echo "$COMPOSE_FILES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate combined service list
run: |
COMPOSE_FILES=$(find . -type f -name "docker-compose*.yml" \
-a ! -name "*windows*" \
-a ! -name "*gui*" \
-a ! -name "*macos*" \
-a ! -name "*hivemind*" \
-a ! -name "*server*" \
| sort)
if [ -z "$COMPOSE_FILES" ]; then
echo "No docker-compose files found. Exiting."
exit 0
fi
echo "Processing combined Compose files:"
echo "$COMPOSE_FILES"
FOUND=0
# Build docker compose arguments
COMPOSE_ARGS=()
while IFS= read -r f; do
COMPOSE_ARGS+=("-f" "$f")
done <<< "$COMPOSE_FILES"
echo "Running: docker compose ${COMPOSE_ARGS[*]} config"
docker compose "${COMPOSE_ARGS[@]}" config --format yaml > merged_compose.yml
if [ ! -s merged_compose.yml ]; then
echo "Merged compose file is empty. Exiting."
exit 1
fi
echo "Merged compose file generated."
# Extract service list with image info
yq -o=json 'explode(.) | .services | to_entries | map({"service": .key, "image": .value.image})' merged_compose.yml \
| jq 'unique_by(.service)' > services.json
FOUND=1
if [ "$FOUND" -eq 0 ]; then
echo "No docker-compose services found. Exiting."
exit 0
fi
echo "Generated services.json with all services and images."
- name: Generate Markdown Table
uses: gazab/create-markdown-table@6686233d7008e8d8b9d4bbdbfd1fb1ae510019f0 # v1.0.7
id: service-table
with:
file: ./services.json
- name: Regenerate README
run: |
echo "# List of Services" > README.md
echo -e "\n\n" >> README.md
echo "${{ steps.service-table.outputs.table }}" >> README.md
- name: Add/Commit README.md
id: commit-readme
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
message: "chore: Update README"
add: "README.md"