Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from using GOV.UK Jenkins to Travis
Browse files Browse the repository at this point in the history
This project isn't owned by GOV.UK Publishing anymore so it needs
to stop using Jenkins to publish changes.

Ideally I'd use a deploy key for this, but it turns out that you can't
attach the same deploy key to more than one repo. This means that we're
going to use a GitHub token attached to the govuk-ci user - this should
be moved to a different user in the future. To make that happen:

- Add the personal access token as a secure Heroku env var
- Change the Git URLs to push over HTTPS, not SSH

The gem_publisher gem expects there to be a file at `.gem/credentials`.
I've encrypted that file for Travis and added that file to the Travis
worker.

Same deal for the `npm publish` command.

It turns out you can only encrypt one file at a time which means
that we need to create a tar archive and then move things around
afterwards which is a little bit horrible.

In order to do this I made a secrets directory and added 2 files:

gem_credentials:

```
---
:rubygems_api_key: redacted
```

npmrc:

```
_auth = redacted
email = [email protected]
```

And then ran:

```
tar cvf secrets.tar secrets/npmrc secrets/gem_credentials
```

And encrypted that file.
alexmuller committed Dec 23, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2a645b8 commit 9db368c
Showing 8 changed files with 25 additions and 23 deletions.
24 changes: 20 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
language: ruby
sudo: false
env:
global:
- secure: "gxjwgl9l9ZP/1t86odZyMzWyiVBkG1oFzeL+Kb6z9Dtfu954l9RbytlenTTcnRw1KtaDBZVBs0ix3K45b8T2S6JFzLQ88Z/36DmXGIN6vxctfnVD9sqbbyOuP++RhibK+qUqbPRHo6a3wBsMQ87DMj5S6pJe3dxbCKRXa8zcMd0="
before_install:
- openssl aes-256-cbc -K $encrypted_df4ab1bff570_key -iv $encrypted_df4ab1bff570_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d
- tar xvf .travis/secrets.tar
- mkdir -p ~/.gem/
- mv secrets/gem_credentials ~/.gem/credentials
- mv secrets/npmrc ~/.npmrc
- git config --global user.name "Travis CI"
- git config --global user.email "[email protected]"
- rm -f Gemfile.lock
- git clean -fdx
install:
# Ensure that Travis install is a no-op because `jenkins.sh`
# installs dependencies.
- echo "Not running Travis installation"
- bundle install
script:
- ./jenkins.sh
- bundle exec rake spec integration_tests
deploy:
- provider: script
script: 'bundle exec rake build:and_release_if_updated'
on:
branch: master
notifications:
email:
on_success: never
Binary file added .travis/secrets.tar.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion build_tools/publisher/docs_publisher.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

module Publisher
class DocsPublisher
GIT_URL = "git@github.com:alphagov/govuk_template"
GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@github.com/alphagov/govuk_template.git"

def initialize(version = GovukTemplate::VERSION)
@version = version
2 changes: 1 addition & 1 deletion build_tools/publisher/ejs_publisher.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

module Publisher
class EJSPublisher
GIT_URL = "git@github.com:alphagov/govuk_template_ejs"
GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@github.com/alphagov/govuk_template_ejs.git"

def initialize(version = GovukTemplate::VERSION)
@version = version
2 changes: 1 addition & 1 deletion build_tools/publisher/jinja_publisher.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

module Publisher
class JinjaPublisher
GIT_URL = "git@github.com:alphagov/govuk_template_jinja"
GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@github.com/alphagov/govuk_template_jinja.git"

def initialize(version = GovukTemplate::VERSION)
@version = version
2 changes: 1 addition & 1 deletion build_tools/publisher/mustache_publisher.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

module Publisher
class MustachePublisher
GIT_URL = "git@github.com:alphagov/govuk_template_mustache"
GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@github.com/alphagov/govuk_template_mustache.git"

def initialize(version = GovukTemplate::VERSION)
@version = version
2 changes: 1 addition & 1 deletion build_tools/publisher/play_publisher.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

module Publisher
class PlayPublisher
GIT_URL = "git@github.com:alphagov/govuk_template_play"
GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@github.com/alphagov/govuk_template_play.git"

def initialize(version = GovukTemplate::VERSION)
@version = version
14 changes: 0 additions & 14 deletions jenkins.sh

This file was deleted.

0 comments on commit 9db368c

Please sign in to comment.