diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index e2546fc..c0442be 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -80,7 +80,7 @@ jobs: docker run --rm \ -e REPO_OWNER=CMSgov \ -e REPO_NAME=github-actions-runner-aws \ - -e PERSONAL_ACCESS_TOKEN=${{ secrets.ROBOT_MAC_FC_TOKEN}} \ + -e PERSONAL_ACCESS_TOKEN=${{ secrets.BHARVEY_GITHUB_TOKEN}} \ -e RUNNER_UUID=${{ needs.set-runner-uuid.outputs.runner-uuid }} \ ${{ env.SHA_TAG }} @@ -95,7 +95,7 @@ jobs: until \ curl -s \ -H "Accept: application/vnd.github.v3+json" \ - -u robot-mac-fc:${{ secrets.ROBOT_MAC_FC_TOKEN }} \ + -u robot-mac-fc:${{ secrets.BHARVEY_GITHUB_TOKEN }} \ https://api.github.com/repos/CMSgov/github-actions-runner-aws/actions/runners \ | jq -e '.runners | .[] | select(.name == "${{ needs.set-runner-uuid.outputs.runner-uuid }}") | .status == "online"' >/dev/null do diff --git a/entrypoint.sh b/entrypoint.sh index 33c04f2..c05e018 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,9 +5,24 @@ mkdir work-dir cd actions-runner # Grab a runner registration token -REGISTRATION_TOKEN=$(curl -s -X POST \ +# https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository +status_code=$(curl \ + -s \ + -w "%{http_code}" \ + -o /tmp/token_response.json \ + -X POST \ -H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \ - "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runners/registration-token" | jq -r .token) + "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runners/registration-token" \ + ) + +if [[ $status_code == "201" ]] +then + REGISTRATION_TOKEN=$(jq -r ".token" /tmp/token_response.json) +else + echo "Got status code $status_code trying to create a GitHub repo registration token." + echo "Response: $(cat /tmp/token_response.json)" + exit 1 +fi # Use the RUNNER_UUID env var if it exists UNIQUE_ID=${RUNNER_UUID:-$(uuidgen)}