forked from matter-labs/zksync
-
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.
- Loading branch information
Showing
140 changed files
with
1,972 additions
and
6,456 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
confVar="$1" | ||
mkdir -p ~/.kube &> /dev/null | ||
|
||
if [ -n "$confVar" ]; then | ||
read KUBECONF <<< $(eval echo \$$confVar) | ||
else | ||
: ${KUBECONF?KUBECONF or envvar name must be provided} | ||
fi | ||
|
||
echo $KUBECONF | base64 -d > ~/.kube/config |
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,109 @@ | ||
#!/bin/bash | ||
## This script updates server-env-custom (merges the etc/env/xxx file with configmap) | ||
# loadtest (without parameters) - combined env | ||
# --repo [loadtest] - env from file | ||
# --kube [loadtest] - env from configmap | ||
# --diff [loadtest] - show the diff to be applied to the configmap | ||
# --merge [loadtest] - writes merged configmap with merged env values | ||
# --update-from fromfile [loadtest] - updates loadtestet env with values fromfile | ||
# --diff-from fromfile [loadtest] - show diff for loadtestet env with values fromfile | ||
|
||
set -e | ||
|
||
serverEnv="server-env-custom" | ||
repoRoot=`cd $( dirname "${BASH_SOURCE[0]}" )/../.. >/dev/null 2>&1 && pwd` | ||
|
||
cmd="$1" | ||
opts="" | ||
|
||
if ( echo "--update-from --diff-from" | grep -qw "\\$cmd" ); then | ||
fromfile="$2" | ||
namespace="${ZKSYNC_ENV:-$3}" | ||
else | ||
namespace="${ZKSYNC_ENV:-$2}" | ||
fi | ||
|
||
[ -z $namespace ] || opts="$opts -n $namespace" | ||
|
||
kube_env() { | ||
if ( kubectl $opts get cm $serverEnv &> /dev/null ); then | ||
kubectl $opts get cm $serverEnv -o go-template --template='{{ range $k,$v := .data}}{{ printf "%s=%s" $k $v }}{{"\n"}}{{end}}' | ||
fi | ||
} | ||
|
||
## | ||
repo_env() { | ||
. $repoRoot/etc/env/$namespace.env | ||
export $(cut -d= -f1 etc/env/$namespace.env | sed -r '/^\s*#/d') | ||
env | sed "/^\($1\)/d" | ||
} | ||
|
||
cmDiff() { | ||
kubectl $opts create cm $serverEnv --from-env-file="$tmpfile" --dry-run -o yaml | kubectl diff -f - || : | ||
} | ||
|
||
cleanup() { | ||
if [ -n "$tmpfile" ]; then | ||
rm -f "$tmpfile" | ||
fi | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
## We call ourself - carefull! | ||
case $cmd in | ||
--kube) | ||
kube_env | ||
;; | ||
--repo) | ||
# current env to sanitize | ||
sanitize=$(env | cut -d= -f1 | sed ':a;N;$!ba;s/\n/\\\|/g') | ||
repo_env "$sanitize" | ||
;; | ||
--diff) | ||
tmpfile=$(mktemp -u) | ||
bash $0 $2 > "$tmpfile" | ||
cmDiff | ||
;; | ||
--merge) | ||
tmpfile=$(mktemp -u) | ||
bash $0 $2 > "$tmpfile" | ||
|
||
# overwrites configmap! | ||
outp=$(cmDiff) | ||
if ( echo "$outp" | grep -Fq '+++' ); then | ||
kubectl $opts create cm $serverEnv --from-env-file="$tmpfile" --dry-run -o yaml | \ | ||
kubectl apply -f - | ||
elif [ -n "$outp" ]; then | ||
# write a error (since no diff) | ||
echo $outp | ||
exit 2 | ||
fi | ||
;; | ||
--update-from) | ||
tmpfile=$(mktemp -u) | ||
{ cat $fromfile; bash $0 --kube $namespace; } | sort -u -t '=' -k 1,1 > "$tmpfile" | ||
|
||
# overwrites configmap! | ||
outp=$(cmDiff) | ||
if ( echo "$outp" | grep -Fq '+++' ); then | ||
kubectl $opts create cm $serverEnv --from-env-file="$tmpfile" --dry-run -o yaml | \ | ||
kubectl apply -f - | ||
elif [ -n "$outp" ]; then | ||
# write a error (since no diff) | ||
echo $outp | ||
exit 2 | ||
fi | ||
;; | ||
--diff-from) | ||
tmpfile=$(mktemp -u) | ||
{ cat $fromfile; bash $0 --kube $namespace; } | sort -u -t '=' -k 1,1 > "$tmpfile" | ||
cmDiff | ||
;; | ||
*) | ||
# Combine two outputs. | ||
# We favour output from kube! | ||
# | ||
{ bash $0 --kube $1; bash $0 --repo $1; } | sort -u -t '=' -k 1,1 | ||
;; | ||
esac |
This file was deleted.
Oops, something went wrong.
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,72 @@ | ||
name: Deploy from Chat | ||
|
||
on: | ||
deployment: | ||
|
||
defaults: | ||
run: | ||
shell: bash -leo pipefail {0} | ||
|
||
# Disable simultaneous deployments into a single environment | ||
concurrency: deploy-chat-${{ github.event.inputs.environment }} | ||
|
||
jobs: | ||
setup: | ||
name: Setup | ||
runs-on: [k8s, stage] | ||
outputs: | ||
image_tag: ${{ steps.set.outputs.shortRev }} | ||
config_tag: ${{ steps.latest.outputs.tag }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- | ||
uses: actions-ecosystem/action-regex-match@v2 | ||
id: regex | ||
with: | ||
text: ${{ github.event.deployment.ref }} | ||
regex: '^(v\d+\.\d+\.\d+)(-r\d+)?$' | ||
- | ||
uses: dysnix/find-latest-tag@v1 | ||
if: steps.regex.outputs.match != '' | ||
id: latest | ||
with: | ||
regex: ${{ steps.regex.outputs.group1 }}(-r\d+)? | ||
token: ${{ secrets.GH_TOKEN }} | ||
repository: matter-labs/configs | ||
- | ||
id: set | ||
run: | | ||
echo "::set-output name=shortRev::$(git rev-parse --short HEAD)" | ||
- | ||
name: Check tag matches pattern | ||
if: steps.regex.outputs.match == '' | ||
uses: chrnorm/deployment-status@releases/v1 | ||
with: | ||
token: ${{ github.token }} | ||
state: failure | ||
deployment_id: ${{ github.event.deployment.id }} | ||
- | ||
if: steps.regex.outputs.match == '' | ||
run: | | ||
echo "::error::Provided ref/tag doesn't match pattern!" | ||
exit 1 | ||
deploy: | ||
name: Deploy environment | ||
runs-on: [k8s, stage] | ||
needs: [setup] | ||
steps: | ||
- name: Deploy | ||
uses: aurelien-baudet/workflow-dispatch@v2 | ||
with: | ||
workflow: Deploy | ||
token: ${{ secrets.GH_TOKEN }} | ||
wait-for-completion-timeout: 10m | ||
wait-for-completion-interval: 1m | ||
inputs: | | ||
{ | ||
"environment": "${{ github.event.deployment.environment }}", | ||
"image_tag": "${{ needs.setup.outputs.image_tag }}", | ||
"config_ref": "${{ needs.setup.outputs.config_tag }}", | ||
"deployment_id": "${{ github.event.deployment.id }}" | ||
} |
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
Oops, something went wrong.