From d2fc70b946dca3185ed9fd17c6b350197e7bc63a Mon Sep 17 00:00:00 2001 From: ein Date: Tue, 8 Feb 2022 10:57:01 -0800 Subject: [PATCH] Adding post stage to gitlab pipeline to sync argo if helm/* was changed, also updating the test script to format your code --- .gitlab-ci.yml | 12 +++++++++--- format_code.sh | 2 +- test-dragon-bot.sh | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 098a633a..44861c9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,10 +40,16 @@ build_and_push_container: - docker build -t ldooks/dragon-bot:$CI_PIPELINE_ID -t ldooks/dragon-bot:latest . - docker push ldooks/dragon-bot:latest - docker push ldooks/dragon-bot:$CI_PIPELINE_ID - - wget https://github.com/argoproj/argo-cd/releases/download/v2.2.5/argocd-linux-amd64 -O /tmp/argocd && chmod +x /tmp/argocd - - /tmp/argocd --insecure --server 192.168.1.205 --auth-token $ARGOCD_TOKEN app sync dragon-bot - #- docker run --rm daangn/argocd-cli sh -c "/usr/local/bin/argocd --insecure --server 192.168.1.205 --auth-token $ARGOCD_TOKEN app sync dragon-bot" rules: - changes: - app/* - Dockerfile + +sync_argo: + stage: .post + script: + - wget https://github.com/argoproj/argo-cd/releases/download/v2.2.5/argocd-linux-amd64 -O /tmp/argocd && chmod +x /tmp/argocd + - /tmp/argocd --insecure --server 192.168.1.205 --auth-token $ARGOCD_TOKEN app sync dragon-bot + rules: + - changes: + - helm/* diff --git a/format_code.sh b/format_code.sh index e3320c5b..63bf36e8 100755 --- a/format_code.sh +++ b/format_code.sh @@ -1 +1 @@ -docker run --rm -ti -v $(pwd):/tmp/python/app python bash -c "cd /tmp/python ; pip install black; black ." +docker run --rm -ti -v $(pwd):/tmp/python/app python:alpine sh -c "cd /tmp/python ; pip install black; black ." diff --git a/test-dragon-bot.sh b/test-dragon-bot.sh index 44547dfa..c9a44067 100755 --- a/test-dragon-bot.sh +++ b/test-dragon-bot.sh @@ -1,4 +1,8 @@ # Remove the running container so we cna re-use the container name 'dragon-bot' +printf "\n[-] Formatting code\n" +./format_code.sh +printf "[+] Done\n" + printf "\n[-] Deleting old dragon-bot container from system\n" docker rm -f dragon-bot-test printf "[+] Done\n"