-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple entrypoint scripts scaffolding
- Loading branch information
Showing
10 changed files
with
127 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Booting containters on the local laptop for debugging purposes..." | ||
echo "Building & booting containters on the local laptop for debugging purposes..." | ||
|
||
GH_REPOSITORY=$(gh repo view --json owner,name -q '.owner.login + "/" + .name') GH_TOKEN=$(gh auth token) docker compose up --build "$@" | ||
GH_REPOSITORY=$(gh repo view --json owner,name -q '.owner.login + "/" + .name') \ | ||
GH_TOKEN=$(gh auth token) \ | ||
docker compose up --build "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -u -e | ||
|
||
if [[ "${GH_REPOSITORY:=}" != */* ]]; then | ||
echo "GH_REPOSITORY must be set, and the format should be {owner}/{repo}."; | ||
exit 1; | ||
fi | ||
|
||
if [[ "${GH_LABELS:=}" == "" ]]; then | ||
echo "GH_LABELS must be set."; | ||
exit 1; | ||
fi | ||
|
||
if [[ "${GH_TOKEN:=}" == "" ]]; then | ||
echo "GH_TOKEN must be set."; | ||
exit 1; | ||
fi | ||
|
||
if [[ "${CI_STORAGE_HOST:=}" != "" && ! "$CI_STORAGE_HOST" =~ ^([-.[:alnum:]]+@)?[-.[:alnum:]]+(:[0-9]+)?$ ]]; then | ||
echo "If CI_STORAGE_HOST is passed, it must be in form of [user@]host[:port]."; | ||
exit 1; | ||
fi | ||
|
||
if [[ "${CI_STORAGE_HOST_PRIVATE_KEY:=}" != "" && "$CI_STORAGE_HOST_PRIVATE_KEY" != *OPENSSH\ PRIVATE\ KEY* ]]; then | ||
echo "If CI_STORAGE_HOST_PRIVATE_KEY is passed, it must be an SSH private key."; | ||
exit 1; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -u -e | ||
|
||
if [[ "$(whoami)" != root ]]; then | ||
echo 'This script must be run as "root" user.'; | ||
exit 1; | ||
fi | ||
|
||
cd / | ||
|
||
for entrypoint in ~/entrypoint.*.sh; do | ||
# shellcheck disable=SC1090 | ||
[[ -f "$entrypoint" ]] && { pushd . >/dev/null; source "$entrypoint"; popd >/dev/null; } | ||
done | ||
|
||
"$@" | ||
|
||
exec gosu user:user ~user/entrypoint.sh |
19 changes: 19 additions & 0 deletions
19
docker/self-hosted-runner/user/entrypoint.00-ci-storage-load.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -u -e | ||
|
||
if [[ "$CI_STORAGE_HOST_PRIVATE_KEY" != "" ]]; then | ||
echo "$CI_STORAGE_HOST_PRIVATE_KEY" > ~/.ssh/id_ed25519 | ||
chmod 600 ~/.ssh/id_ed25519 | ||
fi | ||
|
||
echo "$CI_STORAGE_HOST" > ci-storage-host | ||
|
||
if [[ "$CI_STORAGE_HOST" != "" && "$CI_STORAGE_HOST_PRIVATE_KEY" != "" ]]; then | ||
local_dir=~/actions-runner/_work/${GH_REPOSITORY##*/}/${GH_REPOSITORY##*/} | ||
mkdir -p "$local_dir" | ||
ci-storage load \ | ||
--storage-host="$CI_STORAGE_HOST" \ | ||
--storage-dir="~/ci-storage/$GH_REPOSITORY" \ | ||
--slot-id="?" \ | ||
--local-dir="$local_dir" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -u -e | ||
|
||
cd ~/actions-runner && ./run.sh & wait $! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -u -e | ||
|
||
if [[ "$(whoami)" != user ]]; then | ||
echo 'This script must be run as "user" user.'; | ||
exit 1; | ||
fi | ||
|
||
cd ~user | ||
|
||
echo $$ > .entrypoint.pid | ||
|
||
for entrypoint in ~/entrypoint.*.sh; do | ||
# shellcheck disable=SC1090 | ||
[[ -f "$entrypoint" ]] && { pushd . >/dev/null; source "$entrypoint"; popd >/dev/null; } | ||
done |