From 020da4efc9897835b48e9dcdf55ade66cbddc7fd Mon Sep 17 00:00:00 2001 From: Ori Hoch Date: Thu, 25 Jan 2024 13:32:08 +0200 Subject: [PATCH] deploy to the docker compose server --- .github/workflows/deploy.yml | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 003c208e..99bfc8ab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,10 +85,10 @@ jobs: DOCKER_REPOSITORY_DB: ${{ env.SERVER }}/${{ env.DOCKER_REPOSITORY_DB }} DOCKER_REPOSITORY_DB_BACKUP: ${{ env.SERVER }}/${{ env.DOCKER_REPOSITORY_DB_BACKUP }} DOCKER_REPOSITORY_NGINX: ${{ env.SERVER }}/${{ env.DOCKER_REPOSITORY_NGINX }} - DFC_K8S_DEPLOY_KEY: ${{ secrets.DFC_K8S_DEPLOY_KEY }} + DFC_IAC_DEPLOY_KEY: ${{ secrets.DFC_IAC_DEPLOY_KEY }} ANYWAY_ETL_DEPLOY_KEY: ${{ secrets.ANYWAY_ETL_DEPLOY_KEY }} run: | - if [ "${GITHUB_REF}" == "refs/heads/master" ] || [ "${GITHUB_REF}" == "refs/heads/dev" ]; then + if [ "${GITHUB_REF}" == "refs/heads/master" ]; then SHA_TAG=sha-`git rev-parse --short $GITHUB_SHA` &&\ echo SHA_TAG=$SHA_TAG &&\ ANYWAY_IMAGE="${DOCKER_REPOSITORY_ANYWAY}:${SHA_TAG}" &&\ @@ -101,23 +101,15 @@ jobs: echo NGINX_IMAGE=$NGINX_IMAGE &&\ if ! git log -1 --pretty=format:"%s" | grep -- --no-deploy; then cd `mktemp -d` &&\ - echo "${DFC_K8S_DEPLOY_KEY}" > dfc_k8s_deploy_key &&\ - chmod 400 dfc_k8s_deploy_key &&\ - export GIT_SSH_COMMAND="ssh -i `pwd`/dfc_k8s_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\ - git clone git@github.com:data-for-change/dfc-k8s.git &&\ - cd dfc-k8s &&\ - if [ "${GITHUB_REF}" == "refs/heads/dev" ]; then - python update_yaml.py '{"imageDev":"'${ANYWAY_IMAGE}'","nginxImageDev":"'${NGINX_IMAGE}'"}' apps/anyway/values-anyway-auto-updated.yaml - else - python update_yaml.py '{"image":"'${ANYWAY_IMAGE}'","dbImage":"'${DB_IMAGE}'","dbBackupImage":"'${DB_BACKUP_IMAGE}'","nginxImage":"'${NGINX_IMAGE}'"}' apps/anyway/values-anyway-auto-updated.yaml - fi &&\ + echo "${DFC_IAC_DEPLOY_KEY}" > dfc_iac_deploy_key &&\ + chmod 400 dfc_iac_deploy_key &&\ + export GIT_SSH_COMMAND="ssh -i `pwd`/dfc_iac_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\ + git clone git@github.com:data-for-change/dfc-iac.git &&\ + cd dfc-iac &&\ + bin/update_anyway_env.py '{"image":"'${ANYWAY_IMAGE}'","dbImage":"'${DB_IMAGE}'","dbBackupImage":"'${DB_BACKUP_IMAGE}'","nginxImage":"'${NGINX_IMAGE}'"}' &&\ git config --global user.name "Anyway CI" &&\ git config --global user.email "anyway-ci@localhost" &&\ - if [ "${GITHUB_REF}" == "refs/heads/dev" ]; then - git add apps/anyway/values-anyway-auto-updated.yaml && git commit -m "automatic update of dev anyway" - else - git add apps/anyway/values-anyway-auto-updated.yaml && git commit -m "automatic update of anyway" - fi &&\ + git add apps/anyway/.env && git commit -m "automatic update of anyway" git push origin main &&\ cd `mktemp -d` &&\ echo "${ANYWAY_ETL_DEPLOY_KEY}" > anyway_etl_deploy_key &&\ @@ -125,11 +117,7 @@ jobs: export GIT_SSH_COMMAND="ssh -i `pwd`/anyway_etl_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\ git clone git@github.com:data-for-change/anyway-etl.git &&\ cd anyway-etl &&\ - if [ "${GITHUB_REF}" == "refs/heads/dev" ]; then - ANYWAY_ETL_COMMIT_FILENAME=anyway-dev-commit.txt - else - ANYWAY_ETL_COMMIT_FILENAME=anyway-master-commit.txt - fi &&\ + ANYWAY_ETL_COMMIT_FILENAME=anyway-master-commit.txt echo "${GITHUB_SHA}" > $ANYWAY_ETL_COMMIT_FILENAME &&\ git add ./$ANYWAY_ETL_COMMIT_FILENAME &&\ git commit -m "automatic update of $ANYWAY_ETL_COMMIT_FILENAME" &&\