|
41 | 41 | ./artifacts/microbot-launcher-mac-latest/*.dmg |
42 | 42 | env: |
43 | 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Install jq and verify API secrets |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | + sudo apt-get update |
| 49 | + sudo apt-get install -y jq |
| 50 | + if ! command -v jq >/dev/null 2>&1; then |
| 51 | + echo "::error::jq failed to install"; exit 1; fi |
| 52 | + # Verify required secrets are provided (non-empty) |
| 53 | + if [ -z "${{ secrets.API_EMAIL }}" ]; then |
| 54 | + echo "::error::Missing required secret: API_EMAIL"; exit 1; fi |
| 55 | + if [ -z "${{ secrets.API_PASSWORD }}" ]; then |
| 56 | + echo "::error::Missing required secret: API_PASSWORD"; exit 1; fi |
| 57 | + echo "jq installed and required secrets present" |
| 58 | +
|
| 59 | + - name: Get Auth Token (Launcher Version Update) |
| 60 | + id: auth |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + if ! command -v jq >/dev/null 2>&1; then |
| 64 | + echo "::error::jq not found"; exit 1; fi |
| 65 | + RESPONSE=$(curl -sS --fail \ |
| 66 | + --connect-timeout 10 --max-time 30 \ |
| 67 | + --retry 3 --retry-delay 2 --retry-all-errors \ |
| 68 | + -X POST \ |
| 69 | + -H "Content-Type: application/json" \ |
| 70 | + -d "{\"email\":\"${{ secrets.API_EMAIL }}\",\"password\":\"${{ secrets.API_PASSWORD }}\"}" \ |
| 71 | + https://microbot.cloud/api/auth/login || true) |
| 72 | + TOKEN=$(printf '%s' "$RESPONSE" | jq -er '.token // empty' 2>/dev/null || true) |
| 73 | + if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then |
| 74 | + echo "::error::Failed to obtain auth token"; exit 1; fi |
| 75 | + echo "::add-mask::$TOKEN" |
| 76 | + echo "token=$TOKEN" >> $GITHUB_OUTPUT |
| 77 | +
|
| 78 | + - name: Update Launcher Version in API |
| 79 | + run: | |
| 80 | + set -euo pipefail |
| 81 | + VERSION=${{ steps.version.outputs.version }} |
| 82 | + echo "Updating launcher version to $VERSION via API" |
| 83 | + HTTP_CODE=$(curl -s -o response.json -w "%{http_code}" -X PUT \ |
| 84 | + -H "Authorization: Bearer ${{ steps.auth.outputs.token }}" \ |
| 85 | + -H "Content-Type: application/json" \ |
| 86 | + -d "{\"version\":\"$VERSION\"}" \ |
| 87 | + https://microbot.cloud/api/version/launcher) |
| 88 | + echo "API response (HTTP $HTTP_CODE):"; cat response.json || true |
| 89 | + if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then |
| 90 | + echo "Launcher version updated successfully"; else |
| 91 | + echo "::error::Failed to update launcher version (HTTP $HTTP_CODE)"; exit 1; fi |
0 commit comments