Skip to content

Commit

Permalink
ci: use proper token var
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Apr 4, 2024
1 parent 1e24992 commit 163c2ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/post-create-command.sh
Expand Up @@ -14,5 +14,5 @@ npm install

# run npm start if CODESPACE_NAME starts with "CODESPACE_NAME=nightly-build"
if [[ $CODESPACE_NAME == "ci-nightly-build"* ]]; then
npm start
fi
npm start > npm _start.log 2>&1 &
fi
15 changes: 8 additions & 7 deletions .github/workflows/codespaces-ci.sh
@@ -1,13 +1,14 @@
#!/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"
CODESPACE_NAME="ci-nightly-build-$(date +%s)"
CODESPACE_ID=""
RED='\033[0;35m' # this is not red, it's purple!
RED='\033[0m' # this is not red, it's just to reset the color
GREEN='\033[0;32m'
NC='\033[0m' # No Color

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -121,7 +122,7 @@ function gh_codespace_check_services_status() {

# Wait for all services to start
function wait_for_services() {
echo "Waiting 10 mintues for all dependencies to be installed and starting all services"
echo "Waiting 10 minutes for all dependencies to be installed and starting all services\n"
for i in {1..600}; do
echo -ne "."
sleep 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codespaces-ci.yml
Expand Up @@ -18,5 +18,5 @@ jobs:

- name: Deploy to Codespace
env:
X_GITHUB_TOKEN: ${{ secrets.CODESPACES_TOKEN }}
run: ./.github/workflows/codespaces-ci.sh
X_GITHUB_TOKEN: ${{ secrets.X_GITHUB_TOKEN }}
run: ./.github/workflows/codespaces-ci.sh

0 comments on commit 163c2ef

Please sign in to comment.