diff --git a/.github/workflows/ping-codespace.yml b/.github/workflows/ping-codespace.yml new file mode 100644 index 0000000..732f53d --- /dev/null +++ b/.github/workflows/ping-codespace.yml @@ -0,0 +1,24 @@ +name: Ping Codespace Daily + +on: + schedule: + - cron: "0 2 * * *" + workflow_dispatch: + +jobs: + ping: + runs-on: ubuntu-latest + steps: + - name: Install GitHub CLI + run: sudo apt-get update && sudo apt-get install gh -y + + - name: Auth GitHub CLI + run: echo "${{ secrets.GH_TOKEN }}" | gh auth login --with-token + + - name: List Codespaces + run: gh codespace list + + - name: Ping Codespace + run: | + CODESPACE_NAME="musical-umbrella-694xp6vj96ppfqpj" + gh codespace ssh -c "$CODESPACE_NAME" -d "echo 'Ping at $(date)'" diff --git a/keepalive-all.yml b/keepalive-all.yml new file mode 100644 index 0000000..bec931f --- /dev/null +++ b/keepalive-all.yml @@ -0,0 +1,35 @@ +name: Keep ALL Codespaces Alive via API + +on: + schedule: + - cron: "*/15 * * * *" # jalan tiap 15 menit + workflow_dispatch: + +jobs: + keepalive: + runs-on: ubuntu-latest + steps: + - name: Ping semua Codespace via API + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + echo "Mengambil semua Codespaces..." + CODESPACES=$(curl -s -H "Authorization: token $GH_TOKEN" \ + https://api.github.com/user/codespaces | jq -r '.[].name') + + if [ -z "$CODESPACES" ]; then + echo "Tidak ada Codespace ditemukan ❌" + exit 0 + fi + + for NAME in $CODESPACES; do + echo "Menyalakan Codespace: $NAME..." + curl -s -X POST \ + -H "Authorization: token $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/user/codespaces/$NAME/start \ + > /dev/null + echo "Codespace $NAME diping ✅" + done + + echo "Selesai ping semua Codespace."