diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml deleted file mode 100644 index f874e9c..0000000 --- a/.gitea/workflows/deploy.yml +++ /dev/null @@ -1,201 +0,0 @@ -# Copyright (C) 2026 Moko Consulting -# -# This file is part of a Moko Consulting project. -# -# SPDX-License-Identifier: GPL-3.0-or-later -# -# FILE INFORMATION -# DEFGROUP: GitHub.Workflow -# INGROUP: MokoStandards.Deploy -# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-API -# PATH: /templates/workflows/joomla/deploy.yml.template -# VERSION: 01.01.00 -# BRIEF: Auto-deploy src/ to dev/live servers via SSH rsync on push -# -# Required repo variables: -# DEPLOY_SSH_HOST -- SSH hostname for dev server -# DEPLOY_SSH_USER -- SSH username -# DEPLOY_SSH_PORT -- SSH port (default: 22) -# DEV_DEPLOY_PATH -- Absolute remote path for dev -# LIVE_DEPLOY_PATH -- Absolute remote path for live -# -# Optional repo variables: -# LIVE_SSH_HOST -- SSH hostname for live server (falls back to DEPLOY_SSH_HOST) -# -# Required org/repo secret: -# DEPLOY_SSH_KEY -- Private SSH key for authentication - -name: Deploy - -on: - push: - branches: [dev, main] - paths: - - 'src/**' - - 'htdocs/**' - workflow_dispatch: - inputs: - target: - description: 'Deploy target' - required: true - default: 'dev' - type: choice - options: - - dev - - live - dry_run: - description: 'Dry run (show what would be deployed without deploying)' - required: false - default: false - type: boolean - -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true - -permissions: - contents: read - -jobs: - deploy: - name: Deploy to ${{ github.event_name == 'workflow_dispatch' && inputs.target || (github.ref_name == 'main' && 'Live' || 'Dev') }} - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - - - name: Determine deploy target - id: target - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - TARGET="${{ inputs.target }}" - elif [ "${{ github.ref_name }}" = "main" ]; then - TARGET="live" - else - TARGET="dev" - fi - - echo "env=${TARGET}" >> "$GITHUB_OUTPUT" - - if [ "$TARGET" = "live" ]; then - echo "remote_path=${{ vars.LIVE_DEPLOY_PATH }}" >> "$GITHUB_OUTPUT" - echo "ssh_host=${{ vars.LIVE_SSH_HOST || vars.DEPLOY_SSH_HOST }}" >> "$GITHUB_OUTPUT" - else - echo "remote_path=${{ vars.DEV_DEPLOY_PATH }}" >> "$GITHUB_OUTPUT" - echo "ssh_host=${{ vars.DEPLOY_SSH_HOST }}" >> "$GITHUB_OUTPUT" - fi - - # Resolve source directory - if [ -d "src" ]; then - echo "source_dir=src" >> "$GITHUB_OUTPUT" - elif [ -d "htdocs" ]; then - echo "source_dir=htdocs" >> "$GITHUB_OUTPUT" - else - echo "source_dir=" >> "$GITHUB_OUTPUT" - fi - - - name: Validate configuration - run: | - ERRORS=0 - - if [ -z "${{ steps.target.outputs.ssh_host }}" ]; then - echo "::error::SSH host not configured (DEPLOY_SSH_HOST or LIVE_SSH_HOST)" - ERRORS=$((ERRORS + 1)) - fi - if [ -z "${{ vars.DEPLOY_SSH_USER }}" ]; then - echo "::error::DEPLOY_SSH_USER variable not configured" - ERRORS=$((ERRORS + 1)) - fi - if [ -z "${{ steps.target.outputs.remote_path }}" ]; then - echo "::error::${{ steps.target.outputs.env == 'live' && 'LIVE' || 'DEV' }}_DEPLOY_PATH variable not configured" - ERRORS=$((ERRORS + 1)) - fi - if [ -z "${{ steps.target.outputs.source_dir }}" ]; then - echo "::error::No src/ or htdocs/ directory found -- nothing to deploy" - ERRORS=$((ERRORS + 1)) - fi - - if [ "$ERRORS" -gt 0 ]; then - echo "### Deploy Failed -- Missing Configuration" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "Set the required variables in **Settings > Actions > Variables**." >> "$GITHUB_STEP_SUMMARY" - exit 1 - fi - - - name: Setup SSH - run: | - mkdir -p ~/.ssh - echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - - PORT="${{ vars.DEPLOY_SSH_PORT }}" - [ -z "$PORT" ] && PORT="22" - - ssh-keyscan -p "$PORT" "${{ steps.target.outputs.ssh_host }}" >> ~/.ssh/known_hosts 2>/dev/null - - cat > ~/.ssh/config <> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "| Field | Value |" >> "$GITHUB_STEP_SUMMARY" - echo "|-------|-------|" >> "$GITHUB_STEP_SUMMARY" - echo "| Target | \`${TARGET}\` |" >> "$GITHUB_STEP_SUMMARY" - echo "| Host | \`${{ steps.target.outputs.ssh_host }}\` |" >> "$GITHUB_STEP_SUMMARY" - echo "| Remote | \`${{ steps.target.outputs.remote_path }}\` |" >> "$GITHUB_STEP_SUMMARY" - echo "| Source | \`${{ steps.target.outputs.source_dir }}/\` |" >> "$GITHUB_STEP_SUMMARY" - echo "| Trigger | \`${{ github.event_name }}\` |" >> "$GITHUB_STEP_SUMMARY" - echo "| Branch | \`${{ github.ref_name }}\` |" >> "$GITHUB_STEP_SUMMARY" - if [ "$DRY_RUN" = "true" ]; then - echo "| Mode | **Dry Run** (no files changed) |" >> "$GITHUB_STEP_SUMMARY" - fi