Autodeploydev (#200)

* fix: autodeploy

* added version condition
This commit is contained in:
Christian Jakob 2020-06-10 12:38:13 +02:00 committed by GitHub
parent 207842be91
commit 654bf09ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 0 deletions

54
.github/scripts/githelper.sh vendored Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
#debugger
set -x
source ./.github/scripts/variables.env
############################
function setup_git {
############################
echo "###############"
echo "set git config"
echo "###############"
git config --global user.email "$GIT_USER_MAIL"
git config --global user.name "$GIT_USER_NAME"
}
############################
function checkout_project {
############################
echo "###############"
echo "clone repository $GIT_URL"
echo "###############"
# clone opsrepo
git clone $GIT_URL $LOCAL_TMP_DIR/$GIT_OPSREPO
}
############################
function change_image_version {
############################
echo "###############"
echo "checkout master"
echo "###############"
cd $LOCAL_TMP_DIR/$GIT_OPSREPO/$GIT_OPSREPO_APPFOLDER/$GIT_OPSREPO_APPLICATION_NAME/overlay/$TARGET_ENVIRONMENT
git checkout master
git pull
echo "###############"
echo "change image version and commit"
echo "###############"
sed -i "s#image: $REGISTRY_IMAGE:.*#image: $REGISTRY_IMAGE:$CAOS_NEXT_VERSION#g" $GIT_OPSREPO_IMAGEFILE
git add $GIT_OPSREPO_IMAGEFILE
git commit --message "Github Workflow: $GITHUB_WORKFLOW"
}
############################
function upload_files {
############################
echo "###############"
echo "git push"
echo "###############"
git push --quiet --set-upstream origin
}

21
.github/scripts/variables.env vendored Normal file
View File

@ -0,0 +1,21 @@
### local vars
export LOCAL_TMP_DIR="/tmp"
### git settings for cloning operations repository
export GIT_USER_MAIL="hi@caos.ch"
export GIT_USER_NAME="zitadel-pipeline"
#path of opsrepository
export GIT_URL="https://$GIT_OPSREPO_DEPLOYTOKEN@github.com/caos/zitadel-ops.git"
export GIT_OPSREPO="citadel-ops"
### application settings
export GIT_OPSREPO_APPFOLDER="k8s/workload"
export GIT_OPSREPO_APPLICATION_NAME="zitadel"
export GIT_OPSREPO_IMAGEFILE="imageversion.yaml"
export REGISTRY_IMAGE="$REGISTRY/$GITHUB_REPOSITORY/$IMAGE"
### environment settings
#export TARGET_ENVIRONMENT="dev"

View File

@ -213,3 +213,14 @@ jobs:
- name: Docker Push Latest
run: docker push $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:latest
if: env.CAOS_NEXT_VERSION != ''
- name: Deploy DEV environment
env:
TARGET_ENVIRONMENT: "dev"
GIT_OPSREPO_DEPLOYTOKEN: ${{secrets.GIT_OPSREPO_DEPLOYTOKEN}}
run: |
source ./.github/scripts/githelper.sh
setup_git
checkout_project
change_image_version
upload_files
if: env.CAOS_NEXT_VERSION != ''