mirror of
https://github.com/SebastianKrupinski/action-stalwart-install.git
synced 2026-04-11 20:55:01 +00:00
90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
name: 'Install Stalwart Mail Server'
|
||
description: 'Installs and configures Stalwart email server with optional admin password, domains, and users'
|
||
author: 'Nodarx'
|
||
|
||
branding:
|
||
icon: 'mail'
|
||
color: 'blue'
|
||
|
||
inputs:
|
||
domains:
|
||
description: 'JSON array of domains to create. Example: [{"name":"example.com","description":"Primary domain"}]'
|
||
required: false
|
||
default: ''
|
||
|
||
users:
|
||
description: 'JSON array of users to create. Example: [{"email":"user@example.com","password":"pass123","name":"User Name","quota":1073741824}]'
|
||
required: false
|
||
default: ''
|
||
|
||
runs:
|
||
using: 'composite'
|
||
steps:
|
||
- name: Check prerequisites
|
||
shell: bash
|
||
run: |
|
||
echo "::group::Checking prerequisites"
|
||
|
||
# Check if running as root or if sudo is available
|
||
if [ "$(id -u)" -ne 0 ]; then
|
||
if ! command -v sudo &> /dev/null; then
|
||
echo "::error::This action must run as root or 'sudo' must be available."
|
||
exit 1
|
||
fi
|
||
echo "ℹ Running as non-root user — will use sudo for privileged steps."
|
||
fi
|
||
|
||
# Check for required commands
|
||
for cmd in curl jq tar; do
|
||
if ! command -v $cmd &> /dev/null; then
|
||
echo "::error::Required command '$cmd' not found. Please install it first."
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
echo "✓ All prerequisites met"
|
||
echo "::endgroup::"
|
||
|
||
- name: Install Stalwart Mail Server
|
||
shell: bash
|
||
env:
|
||
STALWART_INSTALL_PATH: '/opt/stalwart'
|
||
run: |
|
||
echo "::group::Installing Stalwart Mail Server"
|
||
chmod +x "${{ github.action_path }}/scripts/install.sh"
|
||
SUDO=""
|
||
if [ "$(id -u)" -ne 0 ]; then SUDO="sudo -E"; fi
|
||
$SUDO "${{ github.action_path }}/scripts/install.sh"
|
||
echo "::endgroup::"
|
||
|
||
- name: Configure Stalwart
|
||
shell: bash
|
||
if: ${{ inputs.domains != '' || inputs.users != '' }}
|
||
env:
|
||
STALWART_DOMAINS: ${{ inputs.domains }}
|
||
STALWART_USERS: ${{ inputs.users }}
|
||
STALWART_INSTALL_PATH: '/opt/stalwart'
|
||
run: |
|
||
|
||
# Mask user passwords from JSON
|
||
if [ -n "$STALWART_USERS" ]; then
|
||
echo "$STALWART_USERS" | jq -r '.[].password // empty' | while read -r pass; do
|
||
if [ -n "$pass" ]; then
|
||
echo "::add-mask::$pass"
|
||
fi
|
||
done
|
||
fi
|
||
|
||
echo "::group::Configuring Stalwart"
|
||
chmod +x "${{ github.action_path }}/scripts/configure.sh"
|
||
SUDO=""
|
||
if [ "$(id -u)" -ne 0 ]; then SUDO="sudo -E"; fi
|
||
$SUDO "${{ github.action_path }}/scripts/configure.sh"
|
||
echo "::endgroup::"
|
||
|
||
- name: Display completion message
|
||
shell: bash
|
||
run: |
|
||
HOSTNAME=$(hostname -f 2>/dev/null || echo "localhost")
|
||
echo "::notice::🎉 Stalwart Mail Server installation complete!"
|
||
echo "::notice::Web admin: http://$HOSTNAME:8080/login" |