connections_migration #5
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
| name: connections_migration | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| connections_config: | |
| description: "Select connections config file" | |
| default: None | |
| type: choice | |
| options: | |
| - None | |
| - dispute_vault | |
| migrate_all_connections: | |
| type: boolean | |
| description: "Migrates all connections from source to target vault." | |
| required: false | |
| default: false | |
| source_vault_id: | |
| description: "Source Vault ID. Required if migrate_all_connections if checked." | |
| required: false | |
| connection_ids: | |
| description: "List of ConnectionId's to be migrated." | |
| required: false | |
| default: "[]" | |
| target_vault_id: | |
| description: "Target Vault ID" | |
| required: true | |
| source_account_access_token: | |
| description: "Access token of the Source Account" | |
| required: true | |
| target_account_access_token: | |
| description: "Access token of the Target Account" | |
| required: true | |
| source_account_id: | |
| description: "Source Account ID. If not provided, will use the repository variable" | |
| required: false | |
| target_account_id: | |
| description: "Target Account ID. If not provided, will use the repository variable" | |
| required: false | |
| env_url: | |
| description: "Select source and target env" | |
| type: choice | |
| default: "Source: SANDBOX, Target: PRODUCTION" | |
| options: | |
| - "Source: SANDBOX, Target: PRODUCTION" | |
| - "Source: SANDBOX, Target: SANDBOX" | |
| - "Source: PRODUCTION, Target: PRODUCTION" | |
| - "Source: PRODUCTION, Target: SANDBOX" | |
| jobs: | |
| execute-roles-migration-script: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install dependencies | |
| run: pip install requests | |
| - name: Parse and map environment URLs | |
| id: map_envs | |
| shell: bash | |
| run: | | |
| input="${{ github.event.inputs.env_url }}" | |
| source_name=$(echo "$input" | sed -n 's/Source: \([^,]*\),.*/\1/p' | xargs) | |
| target_name=$(echo "$input" | sed -n 's/.*Target: \(.*\)/\1/p' | xargs) | |
| get_env_url() { | |
| case "$1" in | |
| SANDBOX) echo "https://manage.skyflowapis-preview.com" ;; | |
| PRODUCTION) echo "https://manage.skyflowapis.com" ;; | |
| *) echo "Invalid environment: $1" >&2; exit 1 ;; | |
| esac | |
| } | |
| # Resolve URLs | |
| source_url=$(get_env_url "$source_name") | |
| target_url=$(get_env_url "$target_name") | |
| echo "source_url=$source_url" >> $GITHUB_OUTPUT | |
| echo "target_url=$target_url" >> $GITHUB_OUTPUT | |
| - name: Run Python script | |
| env: | |
| CONNECTIONS_IDS: ${{ github.event.inputs.connection_ids }} | |
| MIGRATE_ALL_CONNECTIONS: ${{ github.event.inputs.migrate_all_connections }} | |
| SOURCE_VAULT_ID: ${{ github.event.inputs.source_vault_id }} | |
| TARGET_VAULT_ID: ${{ github.event.inputs.target_vault_id }} | |
| SOURCE_ACCOUNT_AUTH: ${{ github.event.inputs.source_account_access_token }} | |
| TARGET_ACCOUNT_AUTH: ${{ github.event.inputs.target_account_access_token }} | |
| SOURCE_ACCOUNT_ID: ${{ github.event.inputs.source_account_id != '' && github.event.inputs.source_account_id || vars.SOURCE_ACCOUNT_ID }} | |
| TARGET_ACCOUNT_ID: ${{ github.event.inputs.target_account_id != '' && github.event.inputs.target_account_id || vars.TARGET_ACCOUNT_ID }} | |
| SOURCE_ENV_URL: ${{ steps.map_envs.outputs.source_url }} | |
| TARGET_ENV_URL: ${{ steps.map_envs.outputs.target_url }} | |
| CONNECTIONS_CONFIG: configs/connections/${{ github.event.inputs.connections_config }}_connections.json | |
| run: python3 migrate_connections.py |