2020-11-14 20:07:14 +09:00
#!/usr/bin/env bash
set -e
tpe = ${ ACCEPTANCE_TEST_SECRET_TYPE }
2021-05-11 06:30:57 +00:00
VALUES_FILE = ${ VALUES_FILE :- $( dirname $0 ) /values.yaml }
2022-02-16 11:42:38 +00:00
kubectl delete secret controller-manager || :
2020-11-14 20:07:14 +09:00
if [ " ${ tpe } " = = "token" ] ; then
2021-05-02 16:31:07 +09:00
if ! kubectl get secret controller-manager -n actions-runner-system >/dev/null; then
kubectl create secret generic controller-manager \
-n actions-runner-system \
--from-literal= github_token = ${ GITHUB_TOKEN : ?GITHUB_TOKEN must not be empty }
fi
2020-11-14 20:07:14 +09:00
elif [ " ${ tpe } " = = "app" ] ; then
kubectl create secret generic controller-manager \
-n actions-runner-system \
--from-literal= github_app_id = ${ APP_ID : ?must not be empty } \
--from-literal= github_app_installation_id = ${ INSTALLATION_ID : ?must not be empty } \
--from-file= github_app_private_key = ${ PRIVATE_KEY_FILE_PATH : ?must not be empty }
else
echo "ACCEPTANCE_TEST_SECRET_TYPE must be set to either \"token\" or \"app\"" 1>& 2
exit 1
fi
2022-02-17 09:16:16 +09:00
if [ -n " ${ WEBHOOK_GITHUB_TOKEN } " ] ; then
kubectl -n actions-runner-system delete secret \
github-webhook-server || :
kubectl -n actions-runner-system create secret generic \
github-webhook-server \
--from-literal= github_token = ${ WEBHOOK_GITHUB_TOKEN : ?WEBHOOK_GITHUB_TOKEN must not be empty }
else
echo 'Skipped deploying secret "github-webhook-server". Set WEBHOOK_GITHUB_TOKEN to deploy.' 1>& 2
fi
2020-11-14 20:31:37 +09:00
tool = ${ ACCEPTANCE_TEST_DEPLOYMENT_TOOL }
if [ " ${ tool } " = = "helm" ] ; then
helm upgrade --install actions-runner-controller \
charts/actions-runner-controller \
-n actions-runner-system \
2020-11-14 21:58:16 +09:00
--create-namespace \
2021-05-02 16:31:07 +09:00
--set syncPeriod = ${ SYNC_PERIOD } \
2021-05-01 08:10:57 +02:00
--set authSecret.create= false \
--set image.repository= ${ NAME } \
2021-05-11 06:30:57 +00:00
--set image.tag= ${ VERSION } \
-f ${ VALUES_FILE }
2022-02-16 11:44:28 +00:00
# To prevent `CustomResourceDefinition.apiextensions.k8s.io "runners.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes`
# errors
kubectl create -f charts/actions-runner-controller/crds || kubectl replace -f charts/actions-runner-controller/crds
2021-04-18 02:44:59 +02:00
kubectl -n actions-runner-system wait deploy/actions-runner-controller --for condition = available --timeout 60s
2020-11-14 20:31:37 +09:00
else
kubectl apply \
-n actions-runner-system \
-f release/actions-runner-controller.yaml
2021-04-18 02:44:59 +02:00
kubectl -n actions-runner-system wait deploy/controller-manager --for condition = available --timeout 120s
2020-11-14 20:31:37 +09:00
fi
2020-11-14 20:07:14 +09:00
# Adhocly wait for some time until actions-runner-controller's admission webhook gets ready
sleep 20
2021-06-28 08:30:32 +09:00
RUNNER_LABEL = ${ RUNNER_LABEL :- self -hosted }
2021-05-11 06:30:57 +00:00
if [ -n " ${ TEST_REPO } " ] ; then
2022-02-17 09:16:28 +09:00
if [ " ${ USE_RUNNERSET } " -ne "false" ] ; then
2021-06-22 17:10:09 +09:00
cat acceptance/testdata/repo.runnerset.yaml | envsubst | kubectl apply -f -
2021-06-23 20:25:03 +09:00
cat acceptance/testdata/repo.runnerset.hra.yaml | envsubst | kubectl apply -f -
2021-06-22 17:10:09 +09:00
else
echo 'Deploying runnerdeployment and hra. Set USE_RUNNERSET if you want to deploy runnerset instead.'
cat acceptance/testdata/repo.runnerdeploy.yaml | envsubst | kubectl apply -f -
cat acceptance/testdata/repo.hra.yaml | envsubst | kubectl apply -f -
fi
2021-05-11 06:30:57 +00:00
else
echo 'Skipped deploying runnerdeployment and hra. Set TEST_REPO to "yourorg/yourrepo" to deploy.'
fi
if [ -n " ${ TEST_ORG } " ] ; then
2022-02-17 09:16:28 +09:00
cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE = TEST_REPO = NAME = org-runnerdeploy envsubst | kubectl apply -f -
2021-05-11 06:30:57 +00:00
2022-02-17 09:16:28 +09:00
if [ -n " ${ TEST_ORG_GROUP } " ] ; then
cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE = TEST_REPO = TEST_GROUP = ${ TEST_ORG_GROUP } NAME = orggroup-runnerdeploy envsubst | kubectl apply -f -
2021-05-11 06:30:57 +00:00
else
2022-02-17 09:16:28 +09:00
echo 'Skipped deploying enterprise runnerdeployment. Set TEST_ORG_GROUP to deploy.'
2021-05-11 06:30:57 +00:00
fi
else
echo 'Skipped deploying organizational runnerdeployment. Set TEST_ORG to deploy.'
fi
2022-02-17 09:16:28 +09:00
if [ -n " ${ TEST_ENTERPRISE } " ] ; then
cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG = TEST_REPO = NAME = enterprise-runnerdeploy envsubst | kubectl apply -f -
if [ -n " ${ TEST_ENTERPRISE_GROUP } " ] ; then
cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG = TEST_REPO = TEST_GROUP = ${ TEST_ENTERPRISE_GROUP } NAME = enterprisegroup-runnerdeploy envsubst | kubectl apply -f -
else
echo 'Skipped deploying enterprise runnerdeployment. Set TEST_ENTERPRISE_GROUP to deploy.'
fi
else
echo 'Skipped deploying enterprise runnerdeployment. Set TEST_ENTERPRISE to deploy.'
fi