-
-
Save rimusz/49aa3cea02cc24dcd2f9ca0729371a0d to your computer and use it in GitHub Desktop.
Git post-receive hook that creates Brigade event
This file contains hidden or 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
#!/bin/bash | |
while read oldrev newrev refname | |
do | |
short_sha=${newrev:0:8} | |
ulid=$(/usr/local/bin/ulid) | |
build_id="acid-worker-${ulid}-${short_sha}" | |
e_build_id=$(echo "$build_id" | base64 -w 0) | |
e_project_id=$(echo "$ACID_PROJECT_ID" | base64 -w 0) | |
e_acidjs=$(git show ${newrev}:acid.js | base64 -w 0) | |
e_payload=$(echo "{}" | base64 -w 0) | |
e_event=$(echo "post-receive" | base64 -w 0) | |
e_provider=$(echo "acid-git-server" | base64 -w 0) | |
e_commit=$(echo "$newrev" | base64 -w 0) | |
echo "Deploying $newrev" | |
cat << EOF > "/tmp/secret.yaml" | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: ${build_id} | |
labels: | |
build: ${ulid} | |
commit: ${newrev} | |
component: build | |
heritage: acid | |
project: ${ACID_PROJECT_ID} | |
data: | |
script: |- | |
${e_acidjs} | |
payload: |- | |
${e_payload} | |
project_id: ${e_project_id} | |
event_type: ${e_event} | |
event_provider: ${e_provider} | |
commit: ${e_commit} | |
build_id: ${e_build_id} | |
EOF | |
#kubectl create secret -f /tmp/secret.yaml | |
echo "Generated:" | |
cat /tmp/secret.yaml | |
kubectl create -f /tmp/secret.yaml | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment