Reusable Upgrade Environment (Linux) #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Version: v1.8 | ||
|
Check failure on line 1 in .github/workflows/sh-upgrade-environment.yml
|
||
| # Reusable Workflow for Environment Upgrade (Linux) | ||
| # Can be called from other workflows to upgrade environments | ||
| # Packages must be built and validated prior to upgrade | ||
| name: Reusable Upgrade Environment (Linux) | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| package_name: | ||
| description: 'Package name list to upgrade (comma-separated for multiple packages)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| target_environment: | ||
| description: 'Target environment for upgrade' | ||
| required: true | ||
| type: string | ||
| project_name: | ||
| description: 'DBmaestro project name' | ||
| required: false | ||
| type: string | ||
| default: 'Demo-PSQL' | ||
| agent_jar_path: | ||
| description: 'Path to DBmaestro Agent JAR file' | ||
| required: false | ||
| type: string | ||
| default: '/opt/dbmaestro/agent/DBmaestroAgent.jar' | ||
| use_ssl: | ||
| description: 'Use SSL for DBmaestro connection' | ||
| required: false | ||
| type: string | ||
| default: 'True' | ||
| detect_from_push: | ||
| description: 'Detect changed packages from git push (true/false)' | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| is_pull_request: | ||
| description: 'Is this a pull request event (true/false)' | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| runner: | ||
| description: 'Runner type (ubuntu-latest or self-hosted)' | ||
| required: false | ||
| type: string | ||
| default: 'ubuntu-latest' | ||
| auth_type: | ||
| description: 'Authentication type' | ||
| required: false | ||
| type: string | ||
| default: 'DBmaestroAccount' | ||
| dbmaestro_server: | ||
| required: true | ||
| dbmaestro_user: | ||
| required: true | ||
| secrets: | ||
| DBMAESTRO_PASSWORD: | ||
| required: true | ||
| outputs: | ||
| upgraded_packages: | ||
| description: 'List of packages that were upgraded' | ||
| value: ${{ jobs.detect_changed_packages.outputs.packages_list }} | ||
| env: | ||
| GIT_DEPTH: 1 | ||
| jobs: | ||
| # Detect changed packages from push or workflow input | ||
| detect_changed_packages: | ||
| name: Detect Changed Packages | ||
| runs-on: ${{ inputs.runner }} | ||
| if: ${{ !inputs.is_pull_request }} | ||
| outputs: | ||
| matrix: ${{ steps.detect.outputs.matrix }} | ||
| has_packages: ${{ steps.detect.outputs.has_packages }} | ||
| packages_list: ${{ steps.detect.outputs.packages_list }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Detect Changed Packages | ||
| id: detect | ||
| uses: DBMaestroDev/github/.github/actions/sh/detect-changed-packages@v1 | ||
| with: | ||
| package_name: ${{ inputs.package_name }} | ||
| detect_from_push: ${{ inputs.detect_from_push }} | ||
| # Detect changed packages for pull requests | ||
| detect_changed_packages_pr: | ||
| name: Detect Changed Packages (Pull Request) | ||
| runs-on: ${{ inputs.runner }} | ||
| if: ${{ inputs.is_pull_request }} | ||
| outputs: | ||
| packages: ${{ steps.detect-pr.outputs.packages }} | ||
| packages_list: ${{ steps.detect-pr.outputs.packages_list }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Detect Changed Folders in packages/ | ||
| id: detect-pr | ||
| uses: DBMaestroDev/github/.github/actions/sh/detect-changed-packages@v1 | ||
| with: | ||
| is_pull_request: true | ||
| # Comment on PR with detected packages | ||
| comment_pr: | ||
| name: Comment PR with Detected Changed Packages | ||
| runs-on: ubuntu-latest | ||
| if: ${{ inputs.is_pull_request }} | ||
| needs: detect_changed_packages_pr | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| - name: Post PR Comment | ||
| uses: DBMaestroDev/github/.github/actions/sh/pr-comment@v1 | ||
| with: | ||
| packages_list: ${{ needs.detect_changed_packages_pr.outputs.packages_list }} | ||
| environment_name: ${{ inputs.target_environment }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| # Upgrade environment with detected packages | ||
| upgrade_environment: | ||
| name: Upgrade Environment | ||
| runs-on: ${{ inputs.runner }} | ||
| needs: detect_changed_packages | ||
| if: | | ||
| !inputs.is_pull_request && | ||
| needs.detect_changed_packages.outputs.has_packages == 'true' | ||
| strategy: | ||
| max-parallel: 1 | ||
| matrix: | ||
| item: ${{ fromJson(needs.detect_changed_packages.outputs.matrix) }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Upgrade Package | ||
| uses: DBMaestroDev/github/.github/actions/sh/upgrade-environment@v1 | ||
| with: | ||
| agent_jar_path: ${{ inputs.agent_jar_path }} | ||
| auth_type: ${{ inputs.auth_type }} | ||
| DBMAESTRO_PASSWORD: ${{ secrets.DBMAESTRO_PASSWORD }} | ||
| dbmaestro_server: ${{ vars.DBMAESTRO_SERVER }} | ||
| dbmaestro_user: ${{ vars.DBMAESTRO_USER }} | ||
| package_name: ${{ matrix.item.package }} | ||
| project_name: ${{ inputs.project_name }} | ||
| target_environment: ${{ inputs.target_environment }} | ||
| use_ssl: ${{ inputs.use_ssl }} | ||