Skip to content

Commit 50e1234

Browse files
committed
Replace Travis CI with GitHub Actions
We want to use GitHub Actions as the tech docs template's continuous integration/continuous deployment service. This commit removes `.travis.yml` and adds equivalent workflows, `test.yaml` and `publish.yaml`. The script to publish to RubyGems was copied from the discourse/publish-rubygems-action [[1]], with a modification to use the github-actions[bot] user for tagging the release following suggestion from fregante/setup-git-user action [[2]]. We avoid using the action directly in accordance with the guidelines in the GDS Way [[3]]. [1]: https://github.com/discourse/publish-rubygems-action/blob/b55d7b9/entrypoint.sh [2]: https://github.com/fregante/setup-git-user/blob/5ede2be/index.js [3]: https://gds-way.cloudapps.digital/standards/source-code.html#using-github-actions-and-workflows Use GitHub Actions bot account for creating release tags
1 parent 209a7ec commit 50e1234

File tree

3 files changed

+85
-19
lines changed

3 files changed

+85
-19
lines changed

.github/workflows/publish.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
concurrency: rubygems
10+
11+
jobs:
12+
deploy:
13+
name: Publish Ruby Gem
14+
environment: rubygems
15+
permissions:
16+
contents: write # needed to be able to tag the release
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- uses: actions/setup-node@v2
23+
with:
24+
cache: 'npm'
25+
node-version: '14'
26+
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
bundler-cache: true
30+
31+
- name: Check if new version to release
32+
id: gem_version
33+
run: |
34+
gem_version=$(ruby -r rubygems -e "puts Gem::Specification::load('govuk_tech_docs.gemspec)').version")
35+
echo "::set-output name=gem_version::$gem_version"
36+
37+
if git fetch origin "refs/tags/v$gem_version" >/dev/null 2>&1
38+
then
39+
echo "Tag 'v$gem_version' already exists"
40+
echo "::set-output name=new_version::false"
41+
else
42+
echo "::set-output name=new_version::true"
43+
fi
44+
45+
- name: Publish
46+
if: ${{ steps.gem_version.outputs.new_version == 'true' }}
47+
env:
48+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
49+
run: |
50+
mkdir -p ~/.gem
51+
52+
cat << EOF > ~/.gem/credentials
53+
---
54+
:rubygems_api_key: ${RUBYGEMS_API_KEY}
55+
EOF
56+
57+
chmod 0600 ~/.gem/credentials
58+
59+
git config user.name "github-actions[bot]"
60+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+
62+
bundle exec rake release

.github/workflows/test.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: '14'
16+
cache: 'npm'
17+
18+
- uses: ruby/setup-ruby@v1
19+
with:
20+
bundler-cache: true
21+
22+
- name: Run tests
23+
run: bundle exec rake

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)