Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/setup-jfrog/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Setup JFrog CLI'
description: 'Configure JFrog CLI with authentication and verify connection'

inputs:
jf-url:
description: 'JFrog Artifactory URL'
required: true
jf-user:
description: 'JFrog username'
required: true
jf-access-token:
description: 'JFrog access token'
required: true

runs:
using: 'composite'
steps:
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@7c95feb32008765e1b4e626b078dfd897c4340ad # v4.4.1
env:
JF_URL: ${{ inputs.jf-url }}
JF_USER: ${{ inputs.jf-user }}
JF_ACCESS_TOKEN: ${{ inputs.jf-access-token }}

- name: Verify JFrog connection
shell: bash
run: |
echo "🔌 Testing JFrog connection..."
if jf rt ping; then
echo "✅ JFrog connection successful"
else
echo "❌ JFrog connection failed"
exit 1
fi
26 changes: 26 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Setup PHP Environment'
description: 'Setup PHP with common extensions for Nextcloud development'

inputs:
php-version:
description: 'PHP version to install'
required: true
default: '8.3'

runs:
using: 'composite'
steps:
- name: Setup PHP ${{ inputs.php-version }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: ${{ inputs.php-version }}
tools: composer:v2
extensions: gd, zip, curl, xml, xmlrpc, mbstring, sqlite, xdebug, pgsql, intl, imagick, gmp, apcu, bcmath, redis, soap, imap, opcache
env:
runner: ubuntu-latest

- name: Verify PHP installation
shell: bash
run: |
echo "📦 PHP Version: $(php -v | head -n1)"
echo "📦 Composer Version: $(composer --version)"
81 changes: 81 additions & 0 deletions .github/scripts/restore-cached-apps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2025 STRATO AG
# SPDX-License-Identifier: AGPL-3.0-or-later

# Script to restore cached apps from JFrog or GitHub cache
# Used by the build-artifact job to restore pre-built app artifacts

set -euo pipefail

# Required environment variables
: "${APPS_TO_RESTORE:?APPS_TO_RESTORE not set}"
: "${GH_TOKEN:?GH_TOKEN not set}"

echo "📦 Restoring cached apps..."

# Process each app in the restore list
echo "$APPS_TO_RESTORE" | jq -c '.[]' | while read -r app_json; do
APP_NAME=$(echo "$app_json" | jq -r '.name')
APP_SHA=$(echo "$app_json" | jq -r '.sha')
APP_PATH=$(echo "$app_json" | jq -r '.path')
SOURCE=$(echo "$app_json" | jq -r '.source')

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Restoring: $APP_NAME (source: $SOURCE)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

if [ "$SOURCE" == "jfrog" ]; then
# Restore from JFrog
JFROG_PATH=$(echo "$app_json" | jq -r '.jfrog_path')
ARCHIVE_NAME="${APP_NAME}-${APP_SHA}.tar.gz"

echo "📥 Downloading from JFrog: $JFROG_PATH"

if jf rt download "$JFROG_PATH" "$ARCHIVE_NAME" --flat=true; then
echo "✅ Downloaded successfully"
echo "Extracting to $APP_PATH..."
mkdir -p "$(dirname "$APP_PATH")"
tar -xzf "$ARCHIVE_NAME" -C "$(dirname "$APP_PATH")"

if [ -d "$APP_PATH" ] && [ -f "$APP_PATH/appinfo/info.xml" ]; then
echo "✅ Restored $APP_NAME from JFrog"
else
echo "❌ Failed to extract or validate $APP_NAME"
exit 1
fi

rm -f "$ARCHIVE_NAME"
else
echo "❌ Failed to download from JFrog"
exit 1
fi

elif [ "$SOURCE" == "github-cache" ]; then
# Restore from GitHub cache
CACHE_KEY=$(echo "$app_json" | jq -r '.cache_key')

echo "💾 Restoring from GitHub cache: $CACHE_KEY"

# Use gh CLI to restore the cache
if gh cache restore "$CACHE_KEY" --key "$CACHE_KEY"; then
echo "✅ Restored $APP_NAME from GitHub cache"

# Validate restoration
if [ ! -d "$APP_PATH" ] || [ ! -f "$APP_PATH/appinfo/info.xml" ]; then
echo "❌ Validation failed for $APP_NAME"
exit 1
fi
else
echo "❌ Failed to restore from GitHub cache"
exit 1
fi
else
echo "❌ Unknown source: $SOURCE"
exit 1
fi
done

echo ""
echo "✅ All cached apps restored successfully"
83 changes: 83 additions & 0 deletions .github/scripts/upload-app-to-jfrog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2025 STRATO AG
# SPDX-License-Identifier: AGPL-3.0-or-later

# Script to upload a built app to JFrog Artifactory
# Used by build-external-apps job after building each app

set -euo pipefail

# Required environment variables
: "${APP_NAME:?APP_NAME not set}"
: "${APP_SHA:?APP_SHA not set}"
: "${APP_PATH:?APP_PATH not set}"
: "${ARTIFACTORY_REPOSITORY_SNAPSHOT:?ARTIFACTORY_REPOSITORY_SNAPSHOT not set}"
: "${CACHE_VERSION:?CACHE_VERSION not set}"
: "${GITHUB_REF_NAME:?GITHUB_REF_NAME not set}"
: "${GITHUB_SHA:?GITHUB_SHA not set}"

echo "=== JFrog Upload Debug Info ==="
echo "📦 Packaging $APP_NAME for JFrog upload..."
echo "App Name: $APP_NAME"
echo "App SHA: $APP_SHA"
echo "App Path: $APP_PATH"
echo "Repository: $ARTIFACTORY_REPOSITORY_SNAPSHOT"
echo "==============================="

# Verify app path exists
if [ ! -d "$APP_PATH" ]; then
echo "❌ ERROR: App path does not exist: $APP_PATH"
exit 1
fi

echo "App directory contents (top level):"
ls -la "$APP_PATH" | head -20

# Create tar.gz archive of the built app (excluding node_modules and other build artifacts)
ARCHIVE_NAME="${APP_NAME}-${APP_SHA}.tar.gz"
echo ""
echo "Creating archive: $ARCHIVE_NAME"
echo "Running: tar -czf \"$ARCHIVE_NAME\" --exclude=\"node_modules\" --exclude=\".git\" --exclude=\"*.log\" -C \"$(dirname "$APP_PATH")\" \"$(basename "$APP_PATH")\""

tar -czf "$ARCHIVE_NAME" \
--exclude="node_modules" \
--exclude=".git" \
--exclude="*.log" \
-C "$(dirname "$APP_PATH")" \
"$(basename "$APP_PATH")"

echo "✓ Archive created successfully"
echo "Archive size:"
ls -lh "$ARCHIVE_NAME"

# Upload to JFrog - store in snapshot repo under apps/
# Include CACHE_VERSION in path to enable complete cache invalidation
JFROG_PATH="${ARTIFACTORY_REPOSITORY_SNAPSHOT}/apps/${CACHE_VERSION}/${APP_NAME}/${ARCHIVE_NAME}"

echo ""
echo "Uploading to JFrog..."
echo "Target Path: $JFROG_PATH"
echo "Properties: app.name=${APP_NAME};app.sha=${APP_SHA};vcs.branch=${GITHUB_REF_NAME};vcs.revision=${GITHUB_SHA}"

if jf rt upload "$ARCHIVE_NAME" "$JFROG_PATH" \
--target-props "app.name=${APP_NAME};app.sha=${APP_SHA};vcs.branch=${GITHUB_REF_NAME};vcs.revision=${GITHUB_SHA}"; then
echo "✅ Successfully uploaded $APP_NAME to JFrog"
echo ""
echo "Verifying upload..."
if jf rt s "$JFROG_PATH"; then
echo "✓ Upload verified - artifact is accessible in JFrog"
else
echo "⚠ Upload succeeded but verification search failed"
fi
else
UPLOAD_EXIT_CODE=$?
echo "❌ Failed to upload to JFrog (exit code: $UPLOAD_EXIT_CODE)"
echo "⚠️ Continuing workflow despite upload failure..."
fi

# Clean up archive
echo ""
echo "Cleaning up local archive..."
rm -f "$ARCHIVE_NAME"
echo "✓ Cleanup complete"
Loading
Loading