|
24 | 24 | YQ_VERSION: v4.44.6 |
25 | 25 |
|
26 | 26 | jobs: |
| 27 | + check-secret: |
| 28 | + runs-on: ubuntu-22.04 |
| 29 | + outputs: |
| 30 | + has-token: ${{ steps.check.outputs.has-token }} |
| 31 | + steps: |
| 32 | + - id: check |
| 33 | + run: echo "has-token=${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN != '' }}" >> "$GITHUB_OUTPUT" |
| 34 | + |
27 | 35 | lint-and-template: |
28 | 36 | runs-on: ubuntu-22.04 |
29 | 37 | outputs: |
|
86 | 94 |
|
87 | 95 | create-release: |
88 | 96 | runs-on: ubuntu-22.04 |
89 | | - needs: [lint-and-template] |
| 97 | + needs: [lint-and-template, check-secret] |
| 98 | + if: needs.check-secret.outputs.has-token == 'true' |
90 | 99 | outputs: |
91 | 100 | customer-id: ${{ steps.create-customer.outputs.customer-id }} |
92 | 101 | channel-slug: ${{ steps.create-release.outputs.channel-slug }} |
@@ -147,7 +156,7 @@ jobs: |
147 | 156 |
|
148 | 157 | - name: Create customer |
149 | 158 | id: create-customer |
150 | | - uses: replicatedhq/replicated-actions/create-customer@main |
| 159 | + uses: replicatedhq/replicated-actions/create-customer@v1.17.0 |
151 | 160 | with: |
152 | 161 | app-slug: ${{ env.APP_SLUG }} |
153 | 162 | api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} |
@@ -348,31 +357,52 @@ jobs: |
348 | 357 | ttl: 1h |
349 | 358 | export-kubeconfig: true |
350 | 359 |
|
351 | | - # Download license using task |
| 360 | + - name: Install Replicated CLI |
| 361 | + run: | |
| 362 | + curl -s -H "Authorization: token ${{ github.token }}" \ |
| 363 | + https://api.github.com/repos/replicatedhq/replicated/releases/latest \ |
| 364 | + | grep "browser_download_url.*_linux_amd64.tar.gz" \ |
| 365 | + | head -1 | cut -d '"' -f 4 \ |
| 366 | + | xargs curl -sL -o replicated.tar.gz |
| 367 | + tar xzf replicated.tar.gz |
| 368 | + sudo mv replicated /usr/local/bin/replicated |
| 369 | + rm replicated.tar.gz |
| 370 | + replicated version |
| 371 | +
|
352 | 372 | - name: Download license |
353 | 373 | id: download-license |
354 | | - working-directory: applications/mlflow |
355 | 374 | run: | |
356 | 375 | mkdir -p /tmp/replicated |
357 | | - CUSTOMER_NAME="${{ needs.create-release.outputs.customer-id }}" |
358 | | - echo "Using customer name: $CUSTOMER_NAME for license download" |
359 | | - echo "Attempting to download license..." |
360 | | - set +e |
361 | | - CUSTOMER_NAME="$CUSTOMER_NAME" task license:download |
362 | | - DOWNLOAD_RESULT=$? |
363 | | - set -e |
364 | | - if [ $DOWNLOAD_RESULT -ne 0 ]; then |
365 | | - echo "Failed to download license. Error code: $DOWNLOAD_RESULT" |
366 | | - echo "Checking if license file exists..." |
367 | | - ls -la /tmp/replicated || true |
368 | | - exit 1 |
369 | | - fi |
370 | | - if [ ! -f "/tmp/replicated/license.yaml" ] || [ ! -s "/tmp/replicated/license.yaml" ]; then |
371 | | - echo "License file is missing or empty!" |
| 376 | + CUSTOMER_NAME="automated-${{ github.run_id }}" |
| 377 | + LICENSE_FILE="/tmp/replicated/license.yaml" |
| 378 | +
|
| 379 | + for attempt in 1 2 3 4 5; do |
| 380 | + echo "Attempt $attempt: Downloading license for customer $CUSTOMER_NAME..." |
| 381 | + if replicated customer download-license \ |
| 382 | + --customer "$CUSTOMER_NAME" \ |
| 383 | + --app "${{ env.APP_SLUG }}" \ |
| 384 | + > "$LICENSE_FILE" 2>/tmp/replicated/download-error.txt; then |
| 385 | + if [ -s "$LICENSE_FILE" ]; then |
| 386 | + echo "License downloaded successfully" |
| 387 | + break |
| 388 | + fi |
| 389 | + fi |
| 390 | + echo "Download failed:" |
| 391 | + cat /tmp/replicated/download-error.txt || true |
| 392 | + if [ "$attempt" -lt 5 ]; then |
| 393 | + echo "Retrying in $((attempt * 5)) seconds..." |
| 394 | + sleep $((attempt * 5)) |
| 395 | + fi |
| 396 | + done |
| 397 | +
|
| 398 | + if [ ! -s "$LICENSE_FILE" ]; then |
| 399 | + echo "ERROR: Failed to download license after 5 attempts" |
372 | 400 | exit 1 |
373 | 401 | fi |
374 | | - echo "License file downloaded successfully to /tmp/replicated/license.yaml" |
375 | | - LICENSE_CONTENT=$(cat /tmp/replicated/license.yaml) |
| 402 | +
|
| 403 | + echo "License file content (first 5 lines):" |
| 404 | + head -n 5 "$LICENSE_FILE" |
| 405 | + LICENSE_CONTENT=$(cat "$LICENSE_FILE") |
376 | 406 | echo "license<<EOF" >> $GITHUB_OUTPUT |
377 | 407 | echo "$LICENSE_CONTENT" >> $GITHUB_OUTPUT |
378 | 408 | echo "EOF" >> $GITHUB_OUTPUT |
@@ -524,13 +554,15 @@ jobs: |
524 | 554 | - name: Archive Customer |
525 | 555 | if: ${{ always() && needs.create-release.outputs.customer-id != '' }} |
526 | 556 | uses: replicatedhq/replicated-actions/archive-customer@v1.17.0 |
| 557 | + continue-on-error: true |
527 | 558 | with: |
528 | 559 | api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} |
529 | 560 | customer-id: ${{ needs.create-release.outputs.customer-id }} |
530 | 561 |
|
531 | 562 | - name: Archive Channel |
532 | 563 | if: ${{ always() && needs.create-release.outputs.channel-slug != '' }} |
533 | 564 | uses: replicatedhq/replicated-actions/archive-channel@v1.17.0 |
| 565 | + continue-on-error: true |
534 | 566 | with: |
535 | 567 | app-slug: ${{ env.APP_SLUG }} |
536 | 568 | api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} |
|
0 commit comments