From 47790554c6c746f16223ffc5288cc8d567e17b78 Mon Sep 17 00:00:00 2001 From: Jacob Woffenden Date: Tue, 10 Dec 2024 17:02:11 +0000 Subject: [PATCH] i love tdt (#475) Signed-off-by: Jacob Woffenden --- .../{publish-gh-pages.yml => publish.yml} | 12 ++++----- .../{build-and-test.yml => test.yml} | 18 ++++++------- Makefile | 23 ++++++++++++++++ README.md | 2 +- config/tech-docs.yml | 1 - scripts/local.sh | 27 ------------------- 6 files changed, 39 insertions(+), 44 deletions(-) rename .github/workflows/{publish-gh-pages.yml => publish.yml} (64%) rename .github/workflows/{build-and-test.yml => test.yml} (52%) create mode 100644 Makefile delete mode 100644 scripts/local.sh diff --git a/.github/workflows/publish-gh-pages.yml b/.github/workflows/publish.yml similarity index 64% rename from .github/workflows/publish-gh-pages.yml rename to .github/workflows/publish.yml index 4df9291a..4f94a1ac 100644 --- a/.github/workflows/publish-gh-pages.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,5 @@ --- -name: Build and Publish +name: ๐Ÿš€ Publish on: push: @@ -17,13 +17,13 @@ jobs: name: Build runs-on: ubuntu-latest container: - image: docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684 # v4.0.0 + image: ghcr.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:aee182dd1dd86696077ea1c3512590f17ceb9f7a47aa5b16ea4f742666911dbd # v5.0.1 permissions: contents: read steps: - name: Checkout id: checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Build id: build @@ -32,7 +32,7 @@ jobs: - name: Upload Artifact id: upload_artifact - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: github-pages path: artifact.tar @@ -53,8 +53,8 @@ jobs: steps: - name: Configure Pages id: configure_pages - uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d # v4.0.0 + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - name: Deploy to GitHub Pages id: deploy_pages - uses: actions/deploy-pages@decdde0ac072f6dcbe43649d82d9c635fff5b4e4 # v4.0.4 \ No newline at end of file + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/test.yml similarity index 52% rename from .github/workflows/build-and-test.yml rename to .github/workflows/test.yml index 0ca54b8a..eb96a106 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ --- -name: Build and Test +name: ๐Ÿงช Test on: pull_request: @@ -13,33 +13,33 @@ jobs: name: Build runs-on: ubuntu-latest container: - image: docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684 # v4.0.0 + image: ghcr.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:aee182dd1dd86696077ea1c3512590f17ceb9f7a47aa5b16ea4f742666911dbd # v5.0.1 permissions: contents: read steps: - name: Checkout id: checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Build id: build run: | /usr/local/bin/package - # @jacobwoffenden: Removed this because this documentation site needs a refactor - # test: - # name: Test + # Commenting out because there are far too many broken links currently + # link-checker: + # name: Link Checker # runs-on: ubuntu-latest # permissions: # contents: read # steps: # - name: Checkout # id: checkout - # uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # - name: Lychee # id: lychee - # uses: lycheeverse/lychee-action@c053181aa0c3d17606addfe97a9075a32723548a # v1.9.3 + # uses: lycheeverse/lychee-action@f81112d0d2814ded911bd23e3beaa9dda9093915 # v2.1.0 # with: # args: --verbose --no-progress './**/*.md' './**/*.html' './**/*.erb' --accept 403,200,429 - # fail: true \ No newline at end of file + # fail: true diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2011b77b --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +.PHONY: package preview + +.DEFAULT_GOAL := preview + +TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE ?= ghcr.io/ministryofjustice/tech-docs-github-pages-publisher +TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE_SHA ?= sha256:aee182dd1dd86696077ea1c3512590f17ceb9f7a47aa5b16ea4f742666911dbd # v5.0.1 + +package: + docker run --rm \ + --name tech-docs-github-pages-publisher \ + --volume $(PWD)/config:/tech-docs-github-pages-publisher/config \ + --volume $(PWD)/source:/tech-docs-github-pages-publisher/source \ + $(TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE)@$(TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE_SHA) \ + /usr/local/bin/package + +preview: + docker run -it --rm \ + --name tech-docs-github-pages-publisher-preview \ + --volume $(PWD)/config:/tech-docs-github-pages-publisher/config \ + --volume $(PWD)/source:/tech-docs-github-pages-publisher/source \ + --publish 4567:4567 \ + $(TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE)@$(TECH_DOCS_GITHUB_PAGES_PUBLISHER_IMAGE_SHA) \ + /usr/local/bin/preview diff --git a/README.md b/README.md index 5261e8cb..8bfdec89 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ When contributing to the user guidance, you should make sure that your changes: To preview the guidance locally on an MoJ Digital and Technology MacBook, you will need Docker, and then you can run: ```sh -bash scripts/local.sh +make preview ``` You can view the guidance on `http://localhost:4567` in your browser. Any content changes you make to your website will be updated in real time. diff --git a/config/tech-docs.yml b/config/tech-docs.yml index e66d017d..a4bc20aa 100644 --- a/config/tech-docs.yml +++ b/config/tech-docs.yml @@ -5,7 +5,6 @@ host: https://user-guidance.analytical-platform.service.justice.gov.uk show_govuk_logo: false service_name: Analytical Platform User Guidance service_link: https://user-guidance.analytical-platform.service.justice.gov.uk -phase: Alpha # Links to show on right-hand-side of header header_links: diff --git a/scripts/local.sh b/scripts/local.sh deleted file mode 100644 index 6ea2e66b..00000000 --- a/scripts/local.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -MODE="${1:-preview}" -TECH_DOCS_PUBLISHER_IMAGE="docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684" # v4.0.0 - -case ${MODE} in -package | preview) - true - ;; -*) - echo "Usage: ${0} [package|preview]" - exit 1 - ;; -esac - -if [[ "$(uname -m)" == "aarch64" ]] || [[ "$(uname -m)" == "arm64" ]] && [[ "$(uname)" != "Darwin" ]]; then - PLATFORM_FLAG="--platform=linux/amd64" -else - PLATFORM_FLAG="" -fi - -docker run -it --rm ${PLATFORM_FLAG} \ - --name "tech-docs-${MODE}" \ - --publish 4567:4567 \ - --volume "${PWD}/config:/app/config" \ - --volume "${PWD}/source:/app/source" \ - "${TECH_DOCS_PUBLISHER_IMAGE}" "/usr/local/bin/${MODE}"