From 6068f874765704a283283090e32f8b399cca5b2a Mon Sep 17 00:00:00 2001 From: Wassim Chegham Date: Thu, 4 Apr 2024 16:08:59 +0200 Subject: [PATCH] ci: use proper token var --- .github/workflows/codespaces-ci.sh | 11 ++++++----- .github/workflows/codespaces-ci.yml | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codespaces-ci.sh b/.github/workflows/codespaces-ci.sh index 85e5b058..33f3de40 100755 --- a/.github/workflows/codespaces-ci.sh +++ b/.github/workflows/codespaces-ci.sh @@ -1,7 +1,8 @@ #!/bin/bash set -e -# IMPORTANT:a valid GITHUB_TOKEN is required to run this script +# IMPORTANT: a valid X_GITHUB_TOKEN is required to run this script +# Token must have the following permissions: 'admin:org', 'codespace', 'repo' GITHUB_REPOSITORY="Azure-Samples/contoso-real-estate" BRANCH="codespaces-ci" @@ -49,9 +50,9 @@ function api_create_codespace() { -f machineType=l'argePremiumLinux' \ -f status='true' \ -f defaultPermissions='true') - CODESPACE_ID=$(echo "$response" | jq '.name') - CODESPACE_URL=$(echo "$response" | jq '.web_url') - CODESPACE_API=$(echo "$response" | jq '.url') + CODESPACE_ID=$(echo "$response" | jq -r '.name') + CODESPACE_URL=$(echo "$response" | jq -r '.web_url') + CODESPACE_API=$(echo "$response" | jq -r '.url') echo "Codespace created and started:" echo " - ID: $CODESPACE_ID" echo " - Web: $CODESPACE_URL" @@ -91,7 +92,7 @@ function gh_codespace_check_services_status() { echo "---------------------------------------------------------------------------------------------------------" for service in $services; do echo -ne "Inspecting: $service ... " - status=$(curl -H "X-Github-Token: $GITHUB_TOKEN" -s -o /dev/null -w "%{http_code}" $service) + status=$(curl -H "X-Github-Token: $X_GITHUB_TOKEN" -s -o /dev/null -w "%{http_code}" $service) if [ $status == 200 ] || [ $status == 404 ]; then echo -e "${GREEN}$status OK${NC}" diff --git a/.github/workflows/codespaces-ci.yml b/.github/workflows/codespaces-ci.yml index 4bcb7e4f..f635f9a4 100644 --- a/.github/workflows/codespaces-ci.yml +++ b/.github/workflows/codespaces-ci.yml @@ -18,5 +18,5 @@ jobs: - name: Deploy to Codespace env: - X_GITHUB_TOKEN: ${{ secrets.CODESPACES_TOKEN }} - run: ./.github/workflows/codespaces-ci.sh \ No newline at end of file + X_GITHUB_TOKEN: ${{ secrets.X_GITHUB_TOKEN }} + run: ./.github/workflows/codespaces-ci.sh