Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit fa84ffd

Browse files
author
Alistair Laing
committed
Merge branch 'master' into extensions
2 parents 82be4b6 + ec39354 commit fa84ffd

6 files changed

Lines changed: 96 additions & 47 deletions

File tree

.travis.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
language: node_js
2+
23
node_js:
3-
- "lts/*"
4-
before_deploy:
5-
- test $TRAVIS_TEST_RESULT = 0
6-
deploy:
7-
- provider: script # (If version.txt is updated) - create a new tag and push to Github, update the latest-release branch
8-
script: ./create-release.sh
9-
on: master
10-
# Automatic deploys are enabled in Heroku for this app
11-
# Every push to master will deploy a new version of this app. Deploys happen automatically.
12-
# Heroku will wait for CI to pass before deploying.
4+
- "lts/*"
5+
- "8"
6+
7+
os:
8+
- linux
9+
- osx
10+
- windows
11+
12+
jobs:
13+
include:
14+
# If version.txt is updated on the master branch:
15+
# - create a new tag and push it to Github
16+
# - update the latest-release branch
17+
- stage: deploy
18+
name: "Create release on GitHub 🚀"
19+
os: linux
20+
script: echo "Checking whether we should release..."
21+
deploy:
22+
- provider: script
23+
script: ./create-release.sh
24+
on:
25+
branch: master
26+
env:
27+
# DEPLOY_KEY
28+
- secure: qpuH/3v+wsMLy9C3bGjallB6KxFQAtDlyZf3jmX8UQ0703tIvBnZoC1h9EJXOqxZbirLPHon7g902nOuhqUfrsPQgV7XEmXMGZsp31PuK/1lkyTCG3fAdeg8wcghwZn10Gw8jYZpOfWIf2GPDL+6utIU6Aog+odcls7tHWLVT80=
29+
30+
# Automatic deploys are also enabled in Heroku for this app
31+
# Every push to master will automatically deploy a new version of this app.
32+
# Heroku will wait for CI to pass before deploying.
33+
1334
notifications:
1435
email: false
36+
1537
sudo: false
16-
env:
17-
global:
18-
- secure: esj3ut+TwKX25QzU1koJyTVIX+x1V55graI65X8LiYXKcOP040VPJ9lIC0HeRs5UViBM0Ur1F93rGdgW2zYVzu5MLZoH7KjpzMcG30x+FDqLChT0JfNcLLtLm/wIhx/OAAmsBxXlvjPp092BeEKd3Jug8d329TxwwK5G5XxAatg=

.travis/README.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
11
# Travis encrypted files
22

3-
This directory contains a public/private keypair generated just for this repository.
3+
This directory contains an encrypted private deploy key with write access to the
4+
Prototype Kit repository.
45

5-
The public key is a deploy key which has been added to the GitHub repo for push access.
6+
It has been encrypted using a key stored in the DEPLOY_KEY environment
7+
variable, which is itself encrypted using `travis encrypt`.
68

7-
The private key is encrypted using `travis encrypt-file` and then committed to this repo.
9+
The deploy key is decrypted in create-release.sh.
810

9-
The decrypt commands are in `.travis.yml`.
11+
To update the key:
1012

11-
To regenerate a key:
13+
1. Generate a new keypair using ssh-keygen
14+
15+
```
16+
ssh-keygen -b 4096 -f .travis/prototype-kit-deploy-key
17+
```
1218

13-
```
14-
ssh-keygen -b 4096 -f .travis/govuk_prototype_kit # Make a new keypair
15-
travis encrypt-file .travis/govuk_prototype_kit # Encrypt the private key
16-
mv govuk_prototype_kit.enc .travis/ # Move the private key to the right place
17-
rm .travis/govuk_prototype_kit # Remove the unencrypted private key
18-
```
19+
2. Add the *public* key as a new [deploy key], with write access to the
20+
repository
21+
22+
```
23+
cat .travis/prototype-kit-deploy-key.pub
24+
```
25+
26+
2. Generate a new random string which we can use as an encryption key
27+
28+
3. Encrypt the private key using ssh-keygen
29+
30+
```
31+
openssl aes-256-cbc -k [encryption key here] \
32+
-in prototype-kit-deploy-key \
33+
-out prototype-kit-deploy-key.enc
34+
```
35+
36+
4. Remove the unencrypted private key and the public key
37+
38+
5. Encrypt the private key using the encryption key
39+
40+
```
41+
travis encrypt DEPLOY_KEY=[encryption key]
42+
```
43+
44+
6. Add the encrypted variable to the environment variables for the deploy job
45+
in .travis.yml
46+
47+
48+
[deploy key]: https://github.com/alphagov/govuk-prototype-kit/settings/keys

.travis/govuk_prototype_kit.enc

-3.17 KB
Binary file not shown.

.travis/govuk_prototype_kit.pub

Lines changed: 0 additions & 1 deletion
This file was deleted.
3.19 KB
Binary file not shown.

create-release.sh

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
#!/bin/bash
22
set -e
33

4-
REPO_PATH='alphagov/govuk-prototype-kit'
5-
6-
echo "Add config for alphagov/$REPO_PATH"
4+
# Check for the TRAVIS environment variable
5+
if [[ -z "${TRAVIS}" ]]; then
6+
echo "⛔️ Refusing to run outside of Travis..."
7+
exit 1
8+
fi
79

10+
# Configure git...
811
git config --global user.name "Travis CI"
912
git config --global user.email "travis@travis-ci.org"
10-
git remote add origin_ssh git@github.com:$REPO_PATH.git
13+
git remote add origin_ssh git@github.com:alphagov/govuk-prototype-kit.git
1114

12-
# This openssl command was generated automatically by `travis encrypt-file`, see `.travis/README.md` for more details
13-
openssl aes-256-cbc -K $encrypted_a0ab9bc5246b_key -iv $encrypted_a0ab9bc5246b_iv -in .travis/govuk_prototype_kit.enc -out ~/.ssh/id_rsa -d
14-
chmod 600 ~/.ssh/id_rsa
15+
# Decrypt deploy key.
16+
#
17+
# See `.travis/README.md` for more details
18+
openssl aes-256-cbc -d -k $DEPLOY_KEY \
19+
-in .travis/prototype-kit-deploy-key.enc \
20+
-out ~/.ssh/id_rsa
1521

16-
echo "Check to see if the version file has been updated"
22+
chmod 600 ~/.ssh/id_rsa
1723

1824
# Get the version from the version file
1925
VERSION_TAG="v`cat VERSION.txt`"
2026

21-
# Create a new tag - if the version file has been updated and a tag for that
22-
# version doesn't already exist
23-
24-
# Check to make sure the tag doesn't already exist
27+
# Check that there's not a tag for the current version already
2528
if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then
26-
echo "Creating new tag: $VERSION_TAG"
27-
28-
# Create a new tag and push to Github
29+
# Create a new tag and push to GitHub.
30+
#
31+
# GitHub will automatically create a release for the tag, ignoring any files
32+
# specified in the .gitattributes file
33+
echo "🏷 Creating new tag: $VERSION_TAG"
2934
git tag $VERSION_TAG
3035
git push origin_ssh $VERSION_TAG
3136

32-
# This tag will trigger the builds for the deploy providers marked "# For tagged commits" in .travis.yml
33-
34-
# Alias branch for the most recently released tag, for easier diffing
35-
# Force push local `master` branch to the `latest-release` branch on Github
37+
# Force push the latest-release branch to this commit
38+
echo "💨 Pushing latest-release branch to GitHub"
3639
git push --force origin_ssh master:latest-release
37-
echo "Pushed latest-release branch to GitHub"
38-
3940
else
40-
echo "Not creating a new tag, or updating the latest-release branch as the tag already exists..."
41+
echo "😴 Current version already exists as a tag on GitHub. Nothing to do."
4142
fi

0 commit comments

Comments
 (0)