fixup! Enhance ARC runner image dockerfiles for RunnerScaleSet compatibility
This commit is contained in:
		
							parent
							
								
									f92200ae81
								
							
						
					
					
						commit
						8a8f28f12d
					
				|  | @ -16,61 +16,6 @@ if [ -n "${STARTUP_DELAY_IN_SECONDS}" ]; then | ||||||
|   sleep "${STARTUP_DELAY_IN_SECONDS}" |   sleep "${STARTUP_DELAY_IN_SECONDS}" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ -z "${GITHUB_URL}" ]; then |  | ||||||
|   log.debug 'Working with public GitHub' |  | ||||||
|   GITHUB_URL="https://github.com/" |  | ||||||
| else |  | ||||||
|   length=${#GITHUB_URL} |  | ||||||
|   last_char=${GITHUB_URL:length-1:1} |  | ||||||
| 
 |  | ||||||
|   [[ $last_char != "/" ]] && GITHUB_URL="$GITHUB_URL/"; : |  | ||||||
|   log.debug "Github endpoint URL ${GITHUB_URL}" |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| if [ -z "${RUNNER_NAME}" ]; then |  | ||||||
|   log.error 'RUNNER_NAME must be set' |  | ||||||
|   exit 1 |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| if [ -n "${RUNNER_ORG}" ] && [ -n "${RUNNER_REPO}" ] && [ -n "${RUNNER_ENTERPRISE}" ]; then |  | ||||||
|   ATTACH="${RUNNER_ORG}/${RUNNER_REPO}" |  | ||||||
| elif [ -n "${RUNNER_ORG}" ]; then |  | ||||||
|   ATTACH="${RUNNER_ORG}" |  | ||||||
| elif [ -n "${RUNNER_REPO}" ]; then |  | ||||||
|   ATTACH="${RUNNER_REPO}" |  | ||||||
| elif [ -n "${RUNNER_ENTERPRISE}" ]; then |  | ||||||
|   ATTACH="enterprises/${RUNNER_ENTERPRISE}" |  | ||||||
| else |  | ||||||
|   log.error 'At least one of RUNNER_ORG, RUNNER_REPO, or RUNNER_ENTERPRISE must be set' |  | ||||||
|   exit 1 |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| if [ -z "${RUNNER_TOKEN}" ]; then |  | ||||||
|   log.error 'RUNNER_TOKEN must be set' |  | ||||||
|   exit 1 |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| if [ -z "${RUNNER_REPO}" ] && [ -n "${RUNNER_GROUP}" ];then |  | ||||||
|   RUNNER_GROUPS=${RUNNER_GROUP} |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| # Hack due to https://github.com/actions/actions-runner-controller/issues/252#issuecomment-758338483 |  | ||||||
| if [ ! -d "${RUNNER_HOME}" ]; then |  | ||||||
|   log.error "$RUNNER_HOME should be an emptyDir mount. Please fix the pod spec." |  | ||||||
|   exit 1 |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| # if this is not a testing environment |  | ||||||
| if [[ "${UNITTEST:-}" == '' ]]; then |  | ||||||
|   sudo chown -R runner:docker "$RUNNER_HOME" |  | ||||||
|   # enable dotglob so we can copy a ".env" file to load in env vars as part of the service startup if one is provided |  | ||||||
|   # loading a .env from the root of the service is part of the actions/runner logic |  | ||||||
|   shopt -s dotglob |  | ||||||
|   # use cp instead of mv to avoid issues when src and dst are on different devices |  | ||||||
|   cp -r "$RUNNER_ASSETS_DIR"/* "$RUNNER_HOME"/ |  | ||||||
|   shopt -u dotglob |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| if ! cd "${RUNNER_HOME}"; then | if ! cd "${RUNNER_HOME}"; then | ||||||
|   log.error "Failed to cd into ${RUNNER_HOME}" |   log.error "Failed to cd into ${RUNNER_HOME}" | ||||||
|   exit 1 |   exit 1 | ||||||
|  | @ -78,21 +23,76 @@ fi | ||||||
| 
 | 
 | ||||||
| # past that point, it's all relative pathes from /runner | # past that point, it's all relative pathes from /runner | ||||||
| 
 | 
 | ||||||
| config_args=() |  | ||||||
| if [ "${RUNNER_FEATURE_FLAG_ONCE:-}" != "true" ] && [ "${RUNNER_EPHEMERAL}" == "true" ]; then |  | ||||||
|   config_args+=(--ephemeral) |  | ||||||
|   log.debug 'Passing --ephemeral to config.sh to enable the ephemeral runner.' |  | ||||||
| fi |  | ||||||
| if [ "${DISABLE_RUNNER_UPDATE:-}" == "true" ]; then |  | ||||||
|   config_args+=(--disableupdate) |  | ||||||
|   log.debug 'Passing --disableupdate to config.sh to disable automatic runner updates.' |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| # This is for registering ARC v0 runners. | # This is for registering ARC v0 runners. | ||||||
| # ARC v1 runners do not need config.sh for registering themselves. | # ARC v1 runners do not need config.sh for registering themselves. | ||||||
| # ARC v1 runners are supposed to given the ACTIONS_RUNNER_INPUT_JITCONFIG envvars | # ARC v1 runners are supposed to given the ACTIONS_RUNNER_INPUT_JITCONFIG envvars | ||||||
| # so we use it as the trigger to skip config.sh. | # so we use it as the trigger to skip config.sh. | ||||||
| if [ -z "${ACTIONS_RUNNER_INPUT_JITCONFIG:-}" ]; then | if [ -z "${ACTIONS_RUNNER_INPUT_JITCONFIG:-}" ]; then | ||||||
|  |   if [ -z "${GITHUB_URL}" ]; then | ||||||
|  |     log.debug 'Working with public GitHub' | ||||||
|  |     GITHUB_URL="https://github.com/" | ||||||
|  |   else | ||||||
|  |     length=${#GITHUB_URL} | ||||||
|  |     last_char=${GITHUB_URL:length-1:1} | ||||||
|  | 
 | ||||||
|  |     [[ $last_char != "/" ]] && GITHUB_URL="$GITHUB_URL/"; : | ||||||
|  |     log.debug "Github endpoint URL ${GITHUB_URL}" | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   if [ -z "${RUNNER_NAME}" ]; then | ||||||
|  |     log.error 'RUNNER_NAME must be set' | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   if [ -n "${RUNNER_ORG}" ] && [ -n "${RUNNER_REPO}" ] && [ -n "${RUNNER_ENTERPRISE}" ]; then | ||||||
|  |     ATTACH="${RUNNER_ORG}/${RUNNER_REPO}" | ||||||
|  |   elif [ -n "${RUNNER_ORG}" ]; then | ||||||
|  |     ATTACH="${RUNNER_ORG}" | ||||||
|  |   elif [ -n "${RUNNER_REPO}" ]; then | ||||||
|  |     ATTACH="${RUNNER_REPO}" | ||||||
|  |   elif [ -n "${RUNNER_ENTERPRISE}" ]; then | ||||||
|  |     ATTACH="enterprises/${RUNNER_ENTERPRISE}" | ||||||
|  |   else | ||||||
|  |     log.error 'At least one of RUNNER_ORG, RUNNER_REPO, or RUNNER_ENTERPRISE must be set' | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   if [ -z "${RUNNER_TOKEN}" ]; then | ||||||
|  |     log.error 'RUNNER_TOKEN must be set' | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   if [ -z "${RUNNER_REPO}" ] && [ -n "${RUNNER_GROUP}" ];then | ||||||
|  |     RUNNER_GROUPS=${RUNNER_GROUP} | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   # Hack due to https://github.com/actions/actions-runner-controller/issues/252#issuecomment-758338483 | ||||||
|  |   if [ ! -d "${RUNNER_HOME}" ]; then | ||||||
|  |     log.error "$RUNNER_HOME should be an emptyDir mount. Please fix the pod spec." | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   # if this is not a testing environment | ||||||
|  |   if [[ "${UNITTEST:-}" == '' ]]; then | ||||||
|  |     sudo chown -R runner:docker "$RUNNER_HOME" | ||||||
|  |     # enable dotglob so we can copy a ".env" file to load in env vars as part of the service startup if one is provided | ||||||
|  |     # loading a .env from the root of the service is part of the actions/runner logic | ||||||
|  |     shopt -s dotglob | ||||||
|  |     # use cp instead of mv to avoid issues when src and dst are on different devices | ||||||
|  |     cp -r "$RUNNER_ASSETS_DIR"/* "$RUNNER_HOME"/ | ||||||
|  |     shopt -u dotglob | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   config_args=() | ||||||
|  |   if [ "${RUNNER_FEATURE_FLAG_ONCE:-}" != "true" ] && [ "${RUNNER_EPHEMERAL}" == "true" ]; then | ||||||
|  |     config_args+=(--ephemeral) | ||||||
|  |     log.debug 'Passing --ephemeral to config.sh to enable the ephemeral runner.' | ||||||
|  |   fi | ||||||
|  |   if [ "${DISABLE_RUNNER_UPDATE:-}" == "true" ]; then | ||||||
|  |     config_args+=(--disableupdate) | ||||||
|  |     log.debug 'Passing --disableupdate to config.sh to disable automatic runner updates.' | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|   update-status "Registering" |   update-status "Registering" | ||||||
| 
 | 
 | ||||||
|   retries_left=10 |   retries_left=10 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue