diff --git a/README.md b/README.md index 671da4c..7c91768 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,9 @@ volumes: - name: runner-dir emptyDir: {} ``` + +## Build the runner on macos + +``` +cd runner && docker buildx build --platform linux/amd64 --push -t edp.buildth.ing/devfw-cicd/ubuntu-host-runner:$(date --utc --iso-8601) . + ``` diff --git a/runner/entrypoint.sh b/runner/entrypoint.sh index 7576b45..52cf182 100755 --- a/runner/entrypoint.sh +++ b/runner/entrypoint.sh @@ -23,6 +23,35 @@ if [ -z "$CALLBACK_URL" ]; then exit 1 fi +if [ -z "$GITHUB_URL" ]; then + echo "GITHUB_URL is not set" + exit 1 +fi + +if [ -z "$RUNNER_NAME" ]; then + echo "RUNNER_NAME is not set" + exit 1 +fi + +if [ -z "$BEARER_TOKEN" ]; then + echo "BEARER_TOKEN is not set" + exit 1 +fi + +function success() { + MSG="$1" + ID=${2:-null} + + call "{\"status\": \"idle\", \"message\": \"$MSG\", \"agent_id\": $ID}" +} + +function call() { + PAYLOAD="$1" + local cb_url=$CALLBACK_URL + [[ $cb_url =~ ^(.*)/status(/)?$ ]] || cb_url="${cb_url}/status" + curl --retry 5 --retry-delay 5 --retry-connrefused --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${cb_url}" || echo "failed to call home: exit code ($?)" +} + # retrieve runner secret from garm RUNNER_SECRET=$(curl --retry 5 --retry-delay 5 --retry-connrefused --fail -v -X GET -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${METADATA_URL}/runner-registration-token/") @@ -36,6 +65,8 @@ forgejo-runner \ forgejo-runner generate-config > config.yml; +success "runner should be working" + unset RUNNER_SECRET unset BEARER_TOKEN