-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
86 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
concurrency: rubygems | ||
|
||
jobs: | ||
deploy: | ||
name: Publish Ruby Gem | ||
environment: rubygems | ||
permissions: | ||
contents: write # needed to be able to tag the release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
cache: 'npm' | ||
node-version: '14' | ||
|
||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Check if new version to release | ||
id: gem_version | ||
run: | | ||
gem_version=$(ruby -r rubygems -e "puts Gem::Specification::load('$(ls *.gemspec)').version") | ||
echo "::set-output name=gem_version::$gem_version" | ||
if git fetch origin "refs/tags/v$gem_version" >/dev/null 2>&1 | ||
then | ||
echo "Tag 'v$gem_version' already exists" | ||
echo "::set-output name=new_version::false" | ||
else | ||
echo "::set-output name=new_version::true" | ||
fi | ||
- name: Publish | ||
if: ${{ steps.gem_version.outputs.new_version == 'true' }} | ||
env: | ||
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
GEM: govuk_tech_docs | ||
run: | | ||
mkdir -p ~/.gem | ||
cat << EOF > ~/.gem/credentials | ||
--- | ||
:rubygems_api_key: ${RUBYGEMS_API_KEY} | ||
EOF | ||
chmod 0600 ~/.gem/credentials | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
bundle exec rake release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
cache: 'npm' | ||
|
||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Run tests | ||
run: bundle exec rake |
This file was deleted.
Oops, something went wrong.