Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to Master for home page featured work sort, end-of-year updates #1372

Merged
merged 12 commits into from
Jan 3, 2024
Merged
18 changes: 9 additions & 9 deletions .github/workflows/deploy_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ jobs:
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
echo "USE_SPACES=FALSE" >> $GITHUB_ENV
echo "AWS_S3_ENDPOINT_URL=None" >> $GITHUB_ENV
echo "AWS_STORAGE_BUCKET_NAME=None" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=None" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=None" >> $GITHUB_ENV
echo "USE_SPACES=TRUE" >> $GITHUB_ENV
echo "AWS_S3_ENDPOINT_URL=${{ secrets.PROD_S3_ENDPOINT_URL }}" >> $GITHUB_ENV
echo "AWS_STORAGE_BUCKET_NAME=${{ secrets.PROD_STORAGE_BUCKET_NAME }}" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.PROD_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.PROD_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV

- name: Set env for staging or dev
if: endsWith(github.ref, '/develop') || contains(env.TAG, '-beta')
Expand All @@ -58,10 +58,10 @@ jobs:
echo "SITE_URL=dev.devinit.org" >> $GITHUB_ENV
echo "DATA_SITE_URL=dev.devinit.org" >> $GITHUB_ENV
echo "USE_SPACES=TRUE" >> $GITHUB_ENV
echo "AWS_S3_ENDPOINT_URL=${{ secrets.PROD_S3_ENDPOINT_URL }}" >> $GITHUB_ENV
echo "AWS_STORAGE_BUCKET_NAME=${{ secrets.PROD_STORAGE_BUCKET_NAME }}" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.PROD_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.PROD_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
echo "AWS_S3_ENDPOINT_URL=${{ secrets.DEV_S3_ENDPOINT_URL }}" >> $GITHUB_ENV
echo "AWS_STORAGE_BUCKET_NAME=${{ secrets.DEV_STORAGE_BUCKET_NAME }}" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.DEV_S3_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.DEV_S3_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV

- name: copy deploy file via ssh
uses: appleboy/[email protected]
Expand Down
18 changes: 9 additions & 9 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ function backup_database {

cd $APP_DIR

log "Starting backup from remote docker machine $(docker-compose ps -q db)"
docker-compose exec -T db pg_dump -U di_website -d di_website > $file_name
log "Starting backup from remote docker machine $(docker compose ps -q db)"
docker compose exec -T db pg_dump -U di_website -d di_website > $file_name

log "Database backup completed..."

Expand All @@ -125,7 +125,7 @@ function search_reindex {
start_new_process "Re-indexing search"
cd $APP_DIR
sleep 60s
docker-compose exec -T ${new_state} python manage.py update_index
docker compose exec -T ${new_state} python manage.py update_index

}

Expand Down Expand Up @@ -209,14 +209,14 @@ function setup_blue_green_deployment {
npm run build

# Attempt to stop new container. Sometimes there is a hanging one still running...
docker-compose stop ${new_state}
docker compose stop ${new_state}
# update the new state container
echo "Update the ${new_state} container"
docker-compose up -d ${new_state}
docker compose up -d ${new_state}

# Check the new state container is ready
echo "Check the ${new_state} container is ready"
docker-compose run --rm --entrypoint /bin/bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
docker compose run --rm --entrypoint /bin/bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
chmod +x ./scripts/activate.sh
./scripts/activate.sh ${new_state} ${state} ${new_upstream} ${key_value_store}

Expand All @@ -230,7 +230,7 @@ function setup_blue_green_deployment {
docker tag diwebsite-redesign_web:new diwebsite-redesign_web:latest

echo "Stop the ${state} container"
docker-compose stop ${state}
docker compose stop ${state}
}

if [ ${args[0]} == 'run' ]
Expand Down Expand Up @@ -261,12 +261,12 @@ then
#run this script within this subprocess
chmod +x scripts/*
source scripts/init.sh
docker-compose -f docker-compose-consul.yml up -d
docker compose -f docker-compose-consul.yml up -d
setup_blue_green_deployment
search_reindex

start_new_process "Generating static assets"
docker-compose exec -T ${new_state} python manage.py collectstatic --noinput
docker compose exec -T ${new_state} python manage.py collectstatic --noinput
sudo chown -R di_website:di_website assets

exit 0
Expand Down
4 changes: 1 addition & 3 deletions di_website/home/templatetags/content_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
@register.simple_tag
def get_featured_pages(page_blocks):
featured_pages = [block.value for block in page_blocks if block.value.live]
ordered_featured_pages = sorted(featured_pages, key=lambda x:
getattr(x.specific, 'publication_date',getattr(x.specific, 'first_published_at', None)), reverse=True)
return ordered_featured_pages
return featured_pages
2 changes: 1 addition & 1 deletion di_website/templates/includes/partials/multi-authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3 class="m-authors__title">
{% if author.value.page %}
<a href="{{ author.value.page }}">{{ author.value.name }}</a>{% if not forloop.last %}, {% endif %}
{% else %}
{% if author.block_type == 'internal_participant'%}
{% if author.block_type == 'internal_participant' and author.value.live %}
<a href="{% pageurl author.value %}?referrer=author">
{{ author.value.name }}
</a>{% if not forloop.last %},{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-consul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ services:

networks:
consul:
external:
name: consul
external: true
name: consul

volumes:
consul:
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ volumes:
networks:
web:
consul:
external:
name: consul
external: true
name: consul
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ wagtail==4.2.4
dj-database-url>=1.0.0,<2.0
psycopg2==2.9.3
gunicorn==20.1.0
gevent==23.9.0
gevent==23.9.1
django-dotenv==1.4.2
django-google-optimize==0.3.0
django-markdownify>=0.9.2,<1.0
Expand Down
4 changes: 2 additions & 2 deletions scripts/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ new_state=$1
old_state=$2
new_upstream=$3
key_value_store=$4
was_state=$(docker-compose run --rm nginx curl ${key_value_store}?raw)
was_state=$(docker compose run --rm nginx curl ${key_value_store}?raw)

pid_was=$(docker exec nginx pidof nginx 2> /dev/null || echo '-')
echo "Activate the ${new_state} container, old Nginx pids: ${pid_was}"

echo "Set the ${new_state} container as working"
docker-compose run --rm nginx curl -X PUT -d ${new_state} ${key_value_store} > /dev/null
docker compose run --rm nginx curl -X PUT -d ${new_state} ${key_value_store} > /dev/null

if [[ ${pid_was} != '-' ]]
then
Expand Down
2 changes: 1 addition & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ then
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:blue
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:green
# cd .
docker-compose up --build -d
docker compose up --build -d
fi
4 changes: 2 additions & 2 deletions scripts/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ key_value_store=$1
state=$2

echo 'Set the previous container as working'
docker-compose run --rm nginx curl -X PUT -d ${state} ${key_value_store} > /dev/null
docker compose run --rm nginx curl -X PUT -d ${state} ${key_value_store} > /dev/null

echo 'Stop the ${old_state} container'
docker-compose stop ${state}
docker compose stop ${state}

echo 'Remove the new image'
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:new
6 changes: 3 additions & 3 deletions scripts/rollback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ echo "Create the diwebsite-redesign_web:${new_state} image"
docker tag diwebsite-redesign_web:new diwebsite-redesign_web:${new_state}

echo "Update the ${new_state} container"
docker-compose up -d ${new_state}
docker compose up -d ${new_state}

echo "Check the ${new_state} container is ready"
docker-compose run --rm --entrypoint bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
docker compose run --rm --entrypoint bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60

./activate.sh ${new_state} ${state} ${new_upstream} ${key_value_store}

echo "Set the ${new_state} image as ${state}"
docker tag diwebsite-redesign_web:${new_state} diwebsite-redesign_web:${state}

echo "Stop the ${state} container"
docker-compose stop ${state}
docker compose stop ${state}
Loading