From 217051064286262e53419d9d0d999f6df477bac7 Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Tue, 18 Oct 2022 18:01:01 +0300 Subject: [PATCH 1/8] Replace deprecated set-output usage --- .github/workflows/deploy_CI.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_CI.yml b/.github/workflows/deploy_CI.yml index 40a62dbb2..2cc368670 100644 --- a/.github/workflows/deploy_CI.yml +++ b/.github/workflows/deploy_CI.yml @@ -25,9 +25,9 @@ jobs: cp deploy.sh deploy_script tar -cvf deploy.tar deploy_script - - name: Extract branch name + - name: Set BRANCH env shell: bash - run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}" + run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV id: extract_branch - name: Set env for develop branch @@ -36,7 +36,6 @@ jobs: echo "ENVIRONMENT=${{ secrets.DEV_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.DEV_HOST }}" >> $GITHUB_ENV echo "USERNAME=${{ secrets.USERNAME }}" >> $GITHUB_ENV - echo "BRANCH=${{ steps.extract_branch.outputs.branch }}" >> $GITHUB_ENV echo "WWW_SITE_URL=dev.devinit.org" >> $GITHUB_ENV echo "SITE_URL=dev.devinit.org" >> $GITHUB_ENV echo "DATA_SITE_URL=dev.devinit.org" >> $GITHUB_ENV @@ -47,7 +46,6 @@ jobs: echo "ENVIRONMENT=${{ secrets.PROD_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.PROD_HOST }}" >> $GITHUB_ENV echo "USERNAME=${{ secrets.USERNAME }}" >> $GITHUB_ENV - echo "BRANCH=${{ steps.extract_branch.outputs.branch }}" >> $GITHUB_ENV echo "WWW_SITE_URL=www.devinit.org" >> $GITHUB_ENV echo "SITE_URL=devinit.org" >> $GITHUB_ENV echo "DATA_SITE_URL=data.devinit.org" >> $GITHUB_ENV From a768d6474df4e228ae95cdb1dfce02a72c2e111f Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Tue, 18 Oct 2022 19:07:59 +0300 Subject: [PATCH 2/8] Exclude beta releases for production deployments --- .github/workflows/deploy_CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_CI.yml b/.github/workflows/deploy_CI.yml index 2cc368670..11093d6dc 100644 --- a/.github/workflows/deploy_CI.yml +++ b/.github/workflows/deploy_CI.yml @@ -30,7 +30,7 @@ jobs: run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV id: extract_branch - - name: Set env for develop branch + - name: Set env for staging or dev if: endsWith(github.ref, '/develop') || ${{ github.event.ref }} =~ ^refs/tags/*-beta* run: | echo "ENVIRONMENT=${{ secrets.DEV_ENV }}" >> $GITHUB_ENV @@ -40,8 +40,8 @@ jobs: echo "SITE_URL=dev.devinit.org" >> $GITHUB_ENV echo "DATA_SITE_URL=dev.devinit.org" >> $GITHUB_ENV - - name: Set env for master branch - if: endsWith(github.ref, '/master') || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+ + - name: Set env for production + if: endsWith(github.ref, '/master') || (${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+ && !(${{ github.event.ref }} =~ ^refs/tags/*-beta*)) run: | echo "ENVIRONMENT=${{ secrets.PROD_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.PROD_HOST }}" >> $GITHUB_ENV From 0594a8f78ff2790a34f93c155aa856d662d0c743 Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Tue, 18 Oct 2022 19:54:20 +0300 Subject: [PATCH 3/8] Force fetch from tags to get latest tags --- deploy.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/deploy.sh b/deploy.sh index e5a16ede0..d4edb8272 100755 --- a/deploy.sh +++ b/deploy.sh @@ -136,23 +136,23 @@ function perform_git_operations { if [ -d $APP_DIR ]; then cd $APP_DIR - { - # Move back to root directory - log "Cloning new content from active branch "$ACTIVE_BRANCH - git fetch - git stash - git checkout $ACTIVE_BRANCH - } || { - log "Failed to update from git repository" - exit 20; - } - if [[ $ACTIVE_BRANCH == *"refs/tags"* ]] then - log "Deployment is from a release tag" + { + log "Cloning new content from a release tag "$ACTIVE_BRANCH + git fetch --tags -f + git stash + git checkout $ACTIVE_BRANCH + } || { + log "Failed to update from git repository" + exit 20; + } else { - log "Hard reset to target branch" + log "Cloning new content from active branch "$ACTIVE_BRANCH + git fetch + git stash + git checkout $ACTIVE_BRANCH git reset --hard origin/$ACTIVE_BRANCH } || { log "Failed to update from git repository" From 847998c2eaf3164b7f59d96b1917c6b5d62ecc37 Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Tue, 18 Oct 2022 20:01:37 +0300 Subject: [PATCH 4/8] Update deploy regex for dev and live --- .github/workflows/deploy_CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_CI.yml b/.github/workflows/deploy_CI.yml index 11093d6dc..21384d16a 100644 --- a/.github/workflows/deploy_CI.yml +++ b/.github/workflows/deploy_CI.yml @@ -16,7 +16,7 @@ jobs: if: contains(' refs/heads/master refs/heads/develop - ', github.ref) || ${{ github.event.ref }} =~ ^refs/tags/*-beta* || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+ + ', github.ref) || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+-beta* || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+ steps: - uses: actions/checkout@v2 - name: zip deploy script @@ -31,7 +31,7 @@ jobs: id: extract_branch - name: Set env for staging or dev - if: endsWith(github.ref, '/develop') || ${{ github.event.ref }} =~ ^refs/tags/*-beta* + if: endsWith(github.ref, '/develop') || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+-beta* run: | echo "ENVIRONMENT=${{ secrets.DEV_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.DEV_HOST }}" >> $GITHUB_ENV @@ -41,7 +41,7 @@ jobs: echo "DATA_SITE_URL=dev.devinit.org" >> $GITHUB_ENV - name: Set env for production - if: endsWith(github.ref, '/master') || (${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+ && !(${{ github.event.ref }} =~ ^refs/tags/*-beta*)) + if: endsWith(github.ref, '/master') || ((${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+) && !(${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+-beta*)) run: | echo "ENVIRONMENT=${{ secrets.PROD_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.PROD_HOST }}" >> $GITHUB_ENV From 3e92d0f4613316ff51e80f967d7f0ba9ebd0654b Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Tue, 18 Oct 2022 20:22:05 +0300 Subject: [PATCH 5/8] Update tag version conditionals --- .github/workflows/deploy_CI.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_CI.yml b/.github/workflows/deploy_CI.yml index 21384d16a..e342d6641 100644 --- a/.github/workflows/deploy_CI.yml +++ b/.github/workflows/deploy_CI.yml @@ -30,8 +30,12 @@ jobs: run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV id: extract_branch + - name: Get Version + if: ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9] + run: echo "TAG=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV + - name: Set env for staging or dev - if: endsWith(github.ref, '/develop') || ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+-beta* + if: endsWith(github.ref, '/develop') || contains(env.TAG, '-beta') run: | echo "ENVIRONMENT=${{ secrets.DEV_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.DEV_HOST }}" >> $GITHUB_ENV @@ -41,7 +45,7 @@ jobs: echo "DATA_SITE_URL=dev.devinit.org" >> $GITHUB_ENV - name: Set env for production - if: endsWith(github.ref, '/master') || ((${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+) && !(${{ github.event.ref }} =~ ^refs/tags/v[0-9]+.[0-9]+.[0-9]+-beta*)) + if: endsWith(github.ref, '/master') || contains(env.TAG, '-beta') != true run: | echo "ENVIRONMENT=${{ secrets.PROD_ENV }}" >> $GITHUB_ENV echo "HOST=${{ secrets.PROD_HOST }}" >> $GITHUB_ENV From 6c3c528dece1f4fa1de3213bfa3fd7b801dc1b3d Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Wed, 19 Oct 2022 02:15:08 +0300 Subject: [PATCH 6/8] Update docker compose --- docker-compose.dev.yml | 2 +- docker-compose.yml | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 8ac32dc7a..1235d292a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -72,7 +72,7 @@ services: worker: depends_on: - - db + - web - rabbitmq build: context: . diff --git a/docker-compose.yml b/docker-compose.yml index 9801d4496..5b9babe92 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -145,7 +145,7 @@ services: worker: depends_on: - - db + - web - rabbitmq env_file: .env environment: diff --git a/requirements.txt b/requirements.txt index eeedd4b73..b4916904e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ beautifulsoup4==4.8 bleach==5.0.1 elasticsearch>=7.0.0,<7.16.3 wagtail-linkchecker==0.6.0 -celery==4.4.7 +celery==4.4.7 # upgrade blocked by wagtail-linkchecker wagtailgeowidget>=6.2.0,<7.0 xlrd>=1.0.0 boxsdk==2.6.1 From 3e01681d6a3d6841f9270b1139335cd278d80664 Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Wed, 19 Oct 2022 02:20:02 +0300 Subject: [PATCH 7/8] Hard code celery broker URL --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5b9babe92..9801d4496 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -145,7 +145,7 @@ services: worker: depends_on: - - web + - db - rabbitmq env_file: .env environment: From f17d099445409075b8f6dfd2a07a22b026279d6c Mon Sep 17 00:00:00 2001 From: "Edwin P. Magezi" Date: Wed, 19 Oct 2022 14:16:15 +0300 Subject: [PATCH 8/8] Change CELERY_BIN path to /usr/local/bin/celery --- config/celery/default/celeryd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/celery/default/celeryd b/config/celery/default/celeryd index 096399025..048499c98 100644 --- a/config/celery/default/celeryd +++ b/config/celery/default/celeryd @@ -8,7 +8,7 @@ CELERYD_NODES="worker1" #CELERYD_NODES=10 # Absolute or relative path to the 'celery' command: -CELERY_BIN="/usr/bin/celery" +CELERY_BIN="/usr/local/bin/celery" #CELERY_BIN="/virtualenvs/def/bin/celery" # App instance to use