Skip to content

Commit

Permalink
Merge pull request #2008 from ministryofjustice/github-action
Browse files Browse the repository at this point in the history
Use a github action to build the publisher image
  • Loading branch information
digitalronin authored Jun 25, 2020
2 parents a965631 + 0b0e856 commit 87cbdc3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/docker-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish docker image

on:
release:
types: [published]

jobs:
push_to_registry:
name: Push image to docker hub
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Build and push publisher image to docker hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
path: runbooks
repository: ministryofjustice/cloud-platform-runbooks
tag_with_ref: true
7 changes: 7 additions & 0 deletions runbooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ This directory contains the source files for the runbooks hosted at https://runb

A CircleCI pipeline compiles the source files from this directory to html, and updates the [target repository].

## Publisher docker image

A github action builds and pushes the [publisher docker image] to docker hub,
whenever a new [release] is created via the github user interface.

[target repository]: https://github.com/ministryofjustice/cloud-platform-runbooks
[publisher docker image]: https://hub.docker.com/repository/docker/ministryofjustice/cloud-platform-runbooks
[release]: https://github.com/ministryofjustice/cloud-platform/releases
15 changes: 3 additions & 12 deletions runbooks/makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
IMAGE := ministryofjustice/cloud-platform-runbooks
VERSION := 1.7 # Change this in .circleci/config.yml if you update it here

.built-docker-image: Dockerfile Gemfile Gemfile.lock
docker build -t $(IMAGE) .
touch .built-docker-image

docker-push: .built-docker-image
docker tag $(IMAGE) $(IMAGE):$(VERSION)
docker push $(IMAGE):$(VERSION)

server: .built-docker-image
server:
mkdir compiled || true
docker run \
-p 4567:4567 \
-v $$(pwd)/source:/app/source \
-v $$(pwd)/compiled:/app/compiled \
-v $$(pwd)/config:/app/config \
-it \
$(IMAGE):$(VERSION) bundle exec middleman server
$(IMAGE) bundle exec middleman server

# The CircleCI build pipeline does this, so it should never
# be necessary to run this task. I'm leaving it here for
# reference, and in case we ever need to push changes
# manually.
build: .built-docker-image
build:
mkdir compiled || true
docker run \
-v $$(pwd)/source:/app/source \
Expand Down

0 comments on commit 87cbdc3

Please sign in to comment.