Table of contents

Deploy emergency publishing banners

There are three types of events that would lead GOV.UK to add an emergency banner to the top of each page on the web site; a notable death, a national emergency or a local emergency.

The GOV.UK on-call escalations contact will tell you when you need to publish an emergency banner. They will ensure that the event is legitimate and provide you with the text for the emergency banner. They will also tell you what type of event it is; you do not need to determine the type of event yourself.

If you need to publish the emergency banner out of hours, you will be instructed to do so either by the GOV.UK on-call escalations contact or the Head of GOV.UK.

Contact numbers for those people are in the opsmanual on GitHub enterprise.

Adding emergency publishing banners

Prerequisites

Before publishing an emergency banner, you will need to know the following. The text required will be supplied by the GOV.UK on-call escalations contact:

Mandatory fields

  • The emergency banner type or campaign class (one of notable-death, national-emergency or local-emergency)
  • Text for the heading.

Optional fields

  • Text for the ‘short description’, which is a sentence displayed under the heading. This is optional.
  • A URL for users to find more information (it might not be provided at first).
  • Anchor text that will be displayed for the more information URL (this will default to “More information” if you do not supply it).

Set up your Fabric scripts

If you’ve not used them before, you’ll need to clone fabric-scripts and follow the setup instructions in the fabric-scripts README.

1) Make sure your copy of fabric-scripts is up to date and on master.

2) Activate your virtual environment for the Fabric scripts if you have set one up. If you have followed the setup guide for the Fabric scripts, this will be:

$ . ~/venv/fabric-scripts/bin/activate

3) Pick your environment, which can be integration, staging, or production. For example, for integration:

export environment=integration

4) If you’d like to double check the environment you have set: echo $environment

Deploy the banner using Jenkins

The data for the emergency banner is stored in Redis. Jenkins is used to set the variables.

1) Navigate to the appropriate deploy Jenkins environment (integration, staging or production)

2) Select the Deploy the emergency banner task.

3) Click Build with Parameters in the left hand menu.

4) Fill in the appropriate variables using the form presented by Jenkins. You should be using the information you gathered in the prerequisites.

5) Click build.

Jenkins Deploy Emergency Banner

Clear caching in frontend, static and whitehall-frontend

1) Run the Fabric task to clear the application template cache for frontend and static:

fab $environment campaigns.clear_cached_templates

2) Clear the cache for whitehall-frontend and frontend by restarting memcached:

fab $environment class:whitehall_frontend app.restart:memcached
fab $environment class:frontend app.restart:memcached

You may also need to restart government-frontend for Whitehall and Travel Advice pages: (Note for the reader: This step may not be necessary anymore due to the addition of the memcache clear above, if this is the case please remove this step as part of your 2ndline testing)

fab $environment class:frontend app.restart:government-frontend

NOTE: The main page updates immediately, however whitehall and travel advice can take a couple of minutes before the banner appears.

Test with cache bust strings

1) Test the changes by visiting pages and adding a cache-bust string. Remember to change the URL based on the environment you are testing in (integration, staging, production).

You can automate this by using the emergency publishing scraper

Check the banner displays as expected and double check the information for the header, short description and link are as they should be. Test the link if it is present. Make sure the banner colour is appropriate - black for a notable death, red for a national emergency, green for a local emergency.

If the banner information is not correct, re-run the Jenkins job to correct it.

Purge the caches and test again

1) Purge our entire origin cache:

fab $environment cache.ban_all

2) If you are in production environment, once the origin cache is purged, purge the CDN cache. At the time of writing, this can only be done one item at a time, and doesn’t work in staging or integration.

You can do so by giving a list of comma separated url paths, the following is a list of the 10 most used pages:

fab $environment
cdn.fastly_purge:/,/search,/state-pension-age,/jobsearch,/vehicle-tax,/government/organisations/hm-revenue-customs,/government/organisations/companies-house,/get-information-about-a-company,/check-uk-visa,/check-vehicle-tax

See these instructions for more details on purging the cache.

3) Check that the emergency banner is visible when accessing the same pages as before but without a cache-bust string.

Unset your environment variable and deactivate your virtual environment

1) Remember to unset your Fabric environment variable:

unset environment

2) Deactivate your virtual environment:

deactivate

Removing emergency publishing banners

Set up your Fabric scripts

Follow the instructions above to set up your Fabric scripts

Remove the banner using Jenkins

1) Navigate to the appropriate deploy Jenkins environment (integration, staging or production)

2) Select the Remove the emergency banner task.

3) Click Build now in the left hand menu.

Jenkins Remove Emergency Banner

Clear application caches and restart Whitehall

Follow the instructions above to


Troubleshooting

Background

The information for the emergency banner is stored in Redis. Static is responsible for displaying the data and we use Jenkins to run rake tasks in static to set or delete the appropriate hash in Redis.

Manually testing the Redis key

You can manually check whether the data has been stored in Redis by the Jenkins job on one of the frontend machines.

From your development machine SSH into a frontend box appropriate to the environment you want to check

ssh frontend1.frontend.integration

Load a Rails console for static:

govuk_app_console static

Check the Redis key exists:

irb(main):001:0> Redis.new.hgetall("emergency_banner")
#> {}

In the above example the key has not been set. A sucessfully set key would return a result similar to the following:

irb(main):001:0> Redis.new.hgetall("emergency_banner")
=> {"campaign_class"=>"notable-death", "heading"=>"The heading", "short_description"=>"The short description", "link"=>"https://www.gov.uk", "link_text"=>"More information about the emergency"}

Manually running the rake task to deploy the emergency banner

If you need to manually run the rake tasks to set the Redis keys for some reason, you can do so (remember to follow the instructions above to clear application template caches, restart Whitehall and purge origin caches afterwards):

1) SSH into a frontend machine appropriate to the environment you are deploying the banner on. For example, for integration:

ssh frontend-1.frontend.integration

2) CD into the directory for static:

cd /var/apps/static

3) Run the rake task to create the emergency banner hash in Redis, substituting the quoted data for the parameters:

sudo -u deploy govuk_setenv static bundle exec rake
emergency_banner:deploy[campaign_class,heading,short_description,link,link_text]

The campaign_class is directly injected into the HTML as a class and must be one of

  • notable-death
  • national-emergency
  • local-emergency

For example, if you are deploying an emergency banner for which you have the following information:

  • Type: Death
  • Heading: Alas poor Yorick
  • Short description: I knew him Horatio
  • URL: https://www.gov.uk
  • Link text: Click for more information

You would enter the following command:

sudo -u deploy govuk_setenv static bundle exec rake
emergency_banner:deploy["notable-death","Alas poor Yorick","I knew him
Horatio","https://www.gov.uk","Click for more information"]

Note there are no spaces after the commas between parameters to the rake task.

Quit your SSH session:

exit

Manually running the rake task to remove an emergency banner

1) As above you first need to SSH into a frontend machine:

ssh frontend-1.frontend.integration

2) CD into the directory for static:

cd /var/apps/static

3) Run the rake task to remove the emergency banner hash from Redis:

sudo -u deploy govuk_setenv static bundle exec rake
emergency_banner:remove

4) Quit your SSH session

exit

Types of emergency banners

Death of a notable person

A large black banner is to be displayed on all GOV.UK pages, including the homepage.

The wording to use in the template will be the official title of the deceased and the years of their life e.g. 'His Royal Highness Henry VIII 1491 to 1547’. The text should link to their official biography.

GOV.UK Homepage

GOV.UK Homepage

Other pages

Notable death

National emergency (level 1 or category 2)

A large red banner is to be displayed on all GOV.UK pages, including the homepage.

GOV.UK Homepage

GOV.UK Homepage

Other pages

National emergency

Localised large-scale emergency (level 2 or category 1)

A large green banner is to be displayed on all GOV.UK pages, including the homepage.

These incidents will not be processed outside of business hours.

GOV.UK Homepage

GOV.UK Homepage

Other pages

Local emergency

This page is owned by #2ndline and needs to be reviewed