Initial commit: self-hosted SFP server deployment repository
Provides GitHub Actions workflows for customers to initialize, update, and monitor their self-hosted SFP Pro server instances. Includes a composite action for CLI installation from Gitea and SSH setup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
name: 'Setup SFP CLI and SSH'
|
||||
description: 'Downloads SFP CLI from Gitea releases and configures SSH access to the target server'
|
||||
|
||||
inputs:
|
||||
gitea-token:
|
||||
description: 'Token for authenticating to source.flxbl.io Gitea API'
|
||||
required: true
|
||||
ssh-private-key:
|
||||
description: 'SSH private key for connecting to the remote server'
|
||||
required: true
|
||||
ssh-host:
|
||||
description: 'Hostname or IP of the target server'
|
||||
required: true
|
||||
cli-version:
|
||||
description: 'SFP CLI version to install (default: latest non-draft release)'
|
||||
required: false
|
||||
default: 'latest'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Install SFP CLI from Gitea
|
||||
shell: bash
|
||||
env:
|
||||
GITEA_TOKEN: ${{ inputs.gitea-token }}
|
||||
CLI_VERSION: ${{ inputs.cli-version }}
|
||||
run: |
|
||||
echo "::group::Install SFP CLI"
|
||||
|
||||
GITEA_API="https://source.flxbl.io/api/v1/repos/flxbl/sfp-pro/releases"
|
||||
|
||||
if [ "$CLI_VERSION" = "latest" ]; then
|
||||
echo "Fetching latest release from Gitea..."
|
||||
RELEASE_INFO=$(curl -sf -H "Authorization: token $GITEA_TOKEN" \
|
||||
"${GITEA_API}?limit=10")
|
||||
|
||||
if [ $? -ne 0 ] || [ -z "$RELEASE_INFO" ]; then
|
||||
echo "Failed to fetch releases from Gitea API"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find first non-draft release that has a .deb asset
|
||||
DEB_URL=$(echo "$RELEASE_INFO" | jq -r '
|
||||
[.[] | select(.draft == false)] | first |
|
||||
.assets[] | select(.name | test("_linux_amd64\\.deb$")) |
|
||||
.browser_download_url')
|
||||
else
|
||||
echo "Fetching release matching version: $CLI_VERSION..."
|
||||
RELEASE_INFO=$(curl -sf -H "Authorization: token $GITEA_TOKEN" \
|
||||
"${GITEA_API}?limit=50")
|
||||
|
||||
if [ $? -ne 0 ] || [ -z "$RELEASE_INFO" ]; then
|
||||
echo "Failed to fetch releases from Gitea API"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find release with matching version in asset names
|
||||
DEB_URL=$(echo "$RELEASE_INFO" | jq -r --arg ver "$CLI_VERSION" '
|
||||
[.[] | select(.draft == false) |
|
||||
select(.assets[]? | .name | contains($ver))] | first |
|
||||
.assets[] | select(.name | test("_linux_amd64\\.deb$")) |
|
||||
.browser_download_url')
|
||||
fi
|
||||
|
||||
if [ -z "$DEB_URL" ] || [ "$DEB_URL" = "null" ]; then
|
||||
echo "No .deb package found for version: $CLI_VERSION"
|
||||
echo "Available releases:"
|
||||
echo "$RELEASE_INFO" | jq -r '[.[] | select(.draft == false)] | .[0:5] | .[] | " - \(.tag_name): \([.assets[].name] | join(", "))"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading SFP CLI from: $DEB_URL"
|
||||
curl -L -f -H "Authorization: token $GITEA_TOKEN" -o /tmp/sfp-pro.deb "$DEB_URL"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to download SFP CLI package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing SFP CLI..."
|
||||
sudo dpkg -i /tmp/sfp-pro.deb || sudo apt-get install -f -y
|
||||
rm -f /tmp/sfp-pro.deb
|
||||
|
||||
echo "SFP CLI installed:"
|
||||
sfp --version
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Setup SSH
|
||||
shell: bash
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }}
|
||||
SSH_HOST: ${{ inputs.ssh-host }}
|
||||
run: |
|
||||
echo "::group::Setup SSH"
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
echo "Adding $SSH_HOST to known hosts..."
|
||||
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
||||
|
||||
echo "SSH configured for $SSH_HOST"
|
||||
echo "::endgroup::"
|
||||
Reference in New Issue
Block a user