|
| 1 | +name: 'Test Deployment' |
| 2 | +description: 'Test deployment using customer workflow' |
| 3 | +inputs: |
| 4 | + app-dir: |
| 5 | + description: 'Application directory containing charts' |
| 6 | + default: 'applications/wg-easy' |
| 7 | + customer-name: |
| 8 | + description: 'Customer name for testing' |
| 9 | + required: true |
| 10 | + cluster-name: |
| 11 | + description: 'Cluster name for testing' |
| 12 | + required: true |
| 13 | + channel-name: |
| 14 | + description: 'Channel name for testing' |
| 15 | + required: false |
| 16 | + channel-id: |
| 17 | + description: 'Channel ID for testing (optional, takes precedence over channel-name)' |
| 18 | + required: false |
| 19 | + helm-version: |
| 20 | + description: 'Helm version to use' |
| 21 | + default: '3.17.3' |
| 22 | + cleanup: |
| 23 | + description: 'Whether to cleanup resources after testing' |
| 24 | + default: 'false' |
| 25 | + |
| 26 | +outputs: |
| 27 | + customer-license: |
| 28 | + description: 'Customer license ID used for testing' |
| 29 | + value: ${{ steps.license.outputs.license-id }} |
| 30 | + |
| 31 | +runs: |
| 32 | + using: 'composite' |
| 33 | + steps: |
| 34 | + - name: Setup tools |
| 35 | + uses: ./.github/actions/setup-tools |
| 36 | + with: |
| 37 | + helm-version: ${{ inputs.helm-version }} |
| 38 | + install-helmfile: 'true' |
| 39 | + |
| 40 | + - name: Create customer |
| 41 | + shell: bash |
| 42 | + working-directory: ${{ inputs.app-dir }} |
| 43 | + run: | |
| 44 | + if [ -n "${{ inputs.channel-id }}" ]; then |
| 45 | + task customer-create \ |
| 46 | + CUSTOMER_NAME="${{ inputs.customer-name }}" \ |
| 47 | + RELEASE_CHANNEL_ID="${{ inputs.channel-id }}" |
| 48 | + else |
| 49 | + task customer-create \ |
| 50 | + CUSTOMER_NAME="${{ inputs.customer-name }}" \ |
| 51 | + RELEASE_CHANNEL="${{ inputs.channel-name }}" |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Get customer license |
| 55 | + id: license |
| 56 | + shell: bash |
| 57 | + working-directory: ${{ inputs.app-dir }} |
| 58 | + run: | |
| 59 | + LICENSE_ID=$(task utils:get-customer-license CUSTOMER_NAME="${{ inputs.customer-name }}" --silent | tail -1) |
| 60 | + echo "license-id=$LICENSE_ID" >> $GITHUB_OUTPUT |
| 61 | + echo "::add-mask::$LICENSE_ID" |
| 62 | +
|
| 63 | + - name: Create cluster with retry |
| 64 | + uses: nick-fields/[email protected] |
| 65 | + with: |
| 66 | + timeout_minutes: 20 |
| 67 | + retry_wait_seconds: 30 |
| 68 | + max_attempts: 3 |
| 69 | + command: | |
| 70 | + cd ${{ inputs.app-dir }} |
| 71 | + task cluster-create CLUSTER_NAME="${{ inputs.cluster-name }}" |
| 72 | +
|
| 73 | + - name: Setup cluster |
| 74 | + shell: bash |
| 75 | + working-directory: ${{ inputs.app-dir }} |
| 76 | + run: | |
| 77 | + task setup-kubeconfig CLUSTER_NAME="${{ inputs.cluster-name }}" |
| 78 | + task cluster-ports-expose CLUSTER_NAME="${{ inputs.cluster-name }}" |
| 79 | +
|
| 80 | + - name: Deploy application |
| 81 | + shell: bash |
| 82 | + working-directory: ${{ inputs.app-dir }} |
| 83 | + run: | |
| 84 | + if [ -n "${{ inputs.channel-id }}" ]; then |
| 85 | + task customer-helm-install \ |
| 86 | + CUSTOMER_NAME="${{ inputs.customer-name }}" \ |
| 87 | + CLUSTER_NAME="${{ inputs.cluster-name }}" \ |
| 88 | + CHANNEL_ID="${{ inputs.channel-id }}" \ |
| 89 | + REPLICATED_LICENSE_ID="${{ steps.license.outputs.license-id }}" |
| 90 | + else |
| 91 | + task customer-helm-install \ |
| 92 | + CUSTOMER_NAME="${{ inputs.customer-name }}" \ |
| 93 | + CLUSTER_NAME="${{ inputs.cluster-name }}" \ |
| 94 | + CHANNEL_SLUG="${{ inputs.channel-name }}" \ |
| 95 | + REPLICATED_LICENSE_ID="${{ steps.license.outputs.license-id }}" |
| 96 | + fi |
| 97 | +
|
| 98 | + - name: Run tests |
| 99 | + shell: bash |
| 100 | + working-directory: ${{ inputs.app-dir }} |
| 101 | + run: task test |
| 102 | + |
| 103 | + # - name: Cleanup resources |
| 104 | + # if: inputs.cleanup == 'true' |
| 105 | + # shell: bash |
| 106 | + # working-directory: ${{ inputs.app-dir }} |
| 107 | + # run: | |
| 108 | + # task cleanup-pr-resources BRANCH_NAME="${{ inputs.customer-name }}" |
0 commit comments