diff options
Diffstat (limited to 'deploy/buildbot')
| -rw-r--r-- | deploy/buildbot/master/master.cfg | 55 | ||||
| -rw-r--r-- | deploy/buildbot/worker/run-worker.sh | 2 |
2 files changed, 57 insertions, 0 deletions
diff --git a/deploy/buildbot/master/master.cfg b/deploy/buildbot/master/master.cfg index 457209e..3f509af 100644 --- a/deploy/buildbot/master/master.cfg +++ b/deploy/buildbot/master/master.cfg @@ -75,6 +75,61 @@ factory.addStep(steps.ShellCommand( name='bundles', command=['./gradlew', 'bundleDesktop', 'bundleWasm', 'bundleNative', 'bundleWeb', 'bundleApk'], env=ENV, haltOnFailure=True)) +# Wait for the GitHub Actions "ios" workflow to finish for this exact commit, +# then pull its "kukuri-ios" artifact so deploy ships it alongside the rest. +factory.addStep(steps.ShellCommand( + name='wait-github-ios', + command=['bash', '-c', ''' +set -e +REPO="ketsuban152/kukuri" +TOKEN="Authorization: Bearer $(cat /run/secrets/github_token)" +SHA=$(git rev-parse HEAD) +DEADLINE=$(( $(date +%s) + 2400 )) +while [ "$(date +%s)" -lt "$DEADLINE" ]; do + RES=$(curl -sf -H "$TOKEN" "https://api.github.com/repos/$REPO/actions/runs?head_sha=$SHA" | python3 -c ' +import json,sys +rs=[r for r in json.load(sys.stdin).get("workflow_runs",[]) if r.get("name")=="ios"] +if rs: print(rs[0]["id"], rs[0]["status"], rs[0].get("conclusion") or "") +' || true) + if [ -n "$RES" ]; then + set -- $RES + if [ "$2" = "completed" ]; then + if [ "$3" = "success" ]; then echo "ios run $1: success"; exit 0; fi + echo "ios run $1 finished with conclusion: $3"; exit 1 + fi + echo "ios run $1: $2..." + else + echo "no ios run for $SHA yet..." + fi + sleep 20 +done +echo "timeout waiting for the ios run"; exit 1 +'''], + env=ENV, haltOnFailure=True, timeout=2700)) +factory.addStep(steps.ShellCommand( + name='fetch-github-ios', + command=['bash', '-c', ''' +set -e +REPO="ketsuban152/kukuri" +TOKEN="Authorization: Bearer $(cat /run/secrets/github_token)" +SHA=$(git rev-parse HEAD) +RUN=$(curl -sf -H "$TOKEN" "https://api.github.com/repos/$REPO/actions/runs?head_sha=$SHA" | python3 -c ' +import json,sys +rs=[r for r in json.load(sys.stdin).get("workflow_runs",[]) if r.get("name")=="ios" and r.get("conclusion")=="success"] +print(rs[0]["id"]) +') +URL=$(curl -sf -H "$TOKEN" "https://api.github.com/repos/$REPO/actions/runs/$RUN/artifacts" | python3 -c ' +import json,sys +a=[x for x in json.load(sys.stdin)["artifacts"] if x["name"]=="kukuri-ios"] +print(a[0]["archive_download_url"]) +') +curl -sfL -H "$TOKEN" -o /tmp/kukuri-ios.zip "$URL" +DIST=modules/orgflow-domain/build/distributions +V=$(ls "$DIST"/kukuri-wasm-web-*.zip | sed "s/.*-\([0-9][^/]*\)\.zip/\1/") +cp /tmp/kukuri-ios.zip "$DIST/kukuri-ios-$V.zip" +echo "staged: $DIST/kukuri-ios-$V.zip" +'''], + env=ENV, haltOnFailure=True)) factory.addStep(steps.ShellCommand( name='deploy-to-lighttpd', command=['bash', '-c', ''' diff --git a/deploy/buildbot/worker/run-worker.sh b/deploy/buildbot/worker/run-worker.sh index 6d9c5ce..4e1a6cd 100644 --- a/deploy/buildbot/worker/run-worker.sh +++ b/deploy/buildbot/worker/run-worker.sh @@ -16,6 +16,8 @@ docker run -d --name kukuri-worker --restart unless-stopped \ -e MASTER=192.168.3.110:9989 \ -v jenkins-data:/var/jenkins_home \ -v /root/buildbot/secrets/worker_pass:/run/secrets/worker_pass:ro \ + -v /root/buildbot/secrets/git_pass:/run/secrets/git_pass:ro \ + -v /root/buildbot/secrets/github_token:/run/secrets/github_token:ro \ kukuri-worker:latest sleep 5 |
