From 9f344b6749f9eec1f93b2c2a320a798c484d6470 Mon Sep 17 00:00:00 2001 From: CeciliaKelley33Mm Date: Sun, 6 Oct 2024 08:11:19 +0700 Subject: [PATCH] persistente data bridge test V0.69 --- .github/workflows/runglobal.yml | 30 ++++++++++++++++++++++++++---- loop.sh | 28 ++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.github/workflows/runglobal.yml b/.github/workflows/runglobal.yml index aa1aa1b..3caeae9 100644 --- a/.github/workflows/runglobal.yml +++ b/.github/workflows/runglobal.yml @@ -8,6 +8,11 @@ on: required: true default: true type: boolean + oldTailscaleHostname: + description: 'Old Tailscale Hostname (not needed)' + required: false + default: '' + type: string permissions: write-all @@ -60,9 +65,26 @@ jobs: sed -i 's/SPOTIFY_CLIENT_SECRET_PLACEHOLDER/${{ secrets.SPOTIFY_CLIENT_SECRET }}/g' docker-compose.yml docker compose up -d & - mkdir /tmp/minecraft - cd /tmp/minecraft - wget -O docker-compose.yml https://raw.githubusercontent.com/CeciliaKelley33Mm/global/refs/heads/master/minecraft-compose.yml + if [ "${{ inputs.oldTailscaleHostname }}" != "" ] then + echo DEBUG: old tailscale hostname is not empty + echo it is AA${{ inputs.oldTailscaleHostname }}AA + + npm install -g serve + + cd /tmp + + aria2c -x 16 -j 16 -s 16 http://$OLD_TAILSCALE_HOSTNAME:5000/archive.tar.gz + + tar xf archive.tar.gz + + cd minecraft + else + echo DEBUG: old tailsale hostname doesn't exist, making minecraft + + mkdir /tmp/minecraft + cd /tmp/minecraft + wget -O docker-compose.yml https://raw.githubusercontent.com/CeciliaKelley33Mm/global/refs/heads/master/minecraft-compose.yml + fi docker compose up -d & cd /tmp/CeciliaKelley33Mm.github.io-main/backend @@ -78,4 +100,4 @@ jobs: wget https://raw.githubusercontent.com/CeciliaKelley33Mm/global/refs/heads/master/loop.sh chmod +x loop.sh - bash loop.sh ${{ inputs.runNext }} $GH_TOKEN global runglobal.yml master global $WEBHOOK_URL + bash loop.sh ${{ inputs.runNext }} $GH_TOKEN global runglobal.yml master global $WEBHOOK_URL true ${{ inputs.oldTailscaleHostname }} diff --git a/loop.sh b/loop.sh index 06e35b1..cabd5ab 100755 --- a/loop.sh +++ b/loop.sh @@ -10,6 +10,9 @@ NAME=$6 WEBHOOK_URL=$7 +IS_GLOBAL=$8 +OLD_TAILSCALE_HOSTNAME=$9 + firstTime=1 alreadyDone=0 @@ -92,12 +95,25 @@ check() { sudo tailscale up --hostname=$hostname --advertise-exit-node --ssh - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "/repos/CeciliaKelley33Mm/$REPO/actions/workflows/$WORKFLOW_FILE/dispatches" \ - -f "ref=$BRANCH" -f "inputs[runNext]=true" + command="gh api " + command+="--method POST " + command+='-H "Accept: application/vnd.github+json" ' + command+='-H "X-GitHub-Api-Version: 2022-11-28" ' + command+="\"/repos/CeciliaKelley33Mm/$REPO/actions/workflows/$WORKFLOW_FILE/dispatches\" " + command+="-f \"ref=$BRANCH\" -f \"inputs[runNext]=true\" " + + if [ "$IS_GLOBAL" == "true" ] && [ "$OLD_TAILSCALE_HOSTNAME" != "" ] then + command+="-f \"inputs[oldTailscaleHostname]=$OLD_TAILSCALE_HOSTNAME\"" + + cd /tmp + + # sudo is necessary because we run minecraft in a docker container + sudo tar cf archive.tar.gz minecraft/ + + serve -p 5000 & + fi + + eval "$command" done }