From 7854f8706d2bfabc56f44d2ab1efdd6b072a1abe Mon Sep 17 00:00:00 2001 From: Mat Moore Date: Tue, 29 Oct 2024 09:53:15 +0000 Subject: [PATCH] update to v4 of tech docs publisher The old link checker is no longer included, so use lychee instead. --- .github/workflows/check-links.yml | 42 ++++++++++++++++------ .github/workflows/publish.yml | 60 +++++++++++++++---------------- makefile | 20 ++++------- 3 files changed, 67 insertions(+), 55 deletions(-) diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml index 0818704..69362c6 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/check-links.yml @@ -1,17 +1,39 @@ -name: Check for broken links - +name: Build and Test on: - workflow_dispatch: pull_request: - paths: - - "source/**" + branches: + - main +permissions: {} jobs: - check_links: + build: + name: Build runs-on: ubuntu-latest container: - image: ministryofjustice/tech-docs-github-pages-publisher:v3 + image: docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684 # v4.0.0 + permissions: + contents: read + steps: + - name: Checkout + id: checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - name: Build + id: build + run: | + /usr/local/bin/package + + test: + name: Test + runs-on: ubuntu-latest + permissions: + contents: read steps: - - uses: actions/checkout@v4 - - name: htmlproofer - run: /scripts/check-url-links.sh + - name: Checkout + id: checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - name: Lychee + id: lychee + uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0 + with: + args: --verbose --no-progress './**/*.md' './**/*.html' './**/*.erb' --exclude-loopback --accept 401,403,200,429 --exclude '^https://github.com/moj-analytical-services/create-a-derived-table' --fallback-extensions 'md,html.md.erb' + fail: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fd526bb..b5054f3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,48 +23,44 @@ jobs: build: runs-on: ubuntu-latest container: - image: ministryofjustice/tech-docs-github-pages-publisher:v3 + image: docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684 # v4.0.0 + permissions: + contents: read steps: - name: Checkout - uses: actions/checkout@v4 - - name: Compile Markdown to HTML and create artifact + id: checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Build + id: build run: | - /scripts/deploy.sh - - name: Upload artifact to be published - uses: actions/upload-artifact@v4 + /usr/local/bin/package + + - name: Upload Artifact + id: upload_artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: github-pages path: artifact.tar retention-days: 1 + overwrite: true - deploy: + publish: needs: build + name: Publish + runs-on: ubuntu-latest environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest + url: ${{ steps.configure_pages.outputs.base_url }} + permissions: + contents: read + id-token: write + pages: write steps: - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - name: Configure Pages + id: configure_pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - url-check: - needs: deploy - runs-on: ubuntu-latest - steps: - - name: Download a Build Artifact from build - uses: actions/download-artifact@v4.1.7 - with: - name: github-pages - path: github-pages - - name: Unpack files and check URL links - run: | - cd github-pages - tar -xvf artifact.tar - npm install linkinator - npx linkinator . --recurse --markdown \ - --skip https://ministryofjustice.github.io/find-moj-data-user-guide/images/govuk-large.png \ - --skip https://github.com/moj-analytical-services/create-a-derived-table \ - # "URL Check will fail on private and internal GitHub repositories" + - name: Deploy to GitHub Pages + id: deploy_pages + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/makefile b/makefile index af0f79d..3cb6c84 100644 --- a/makefile +++ b/makefile @@ -1,23 +1,17 @@ -IMAGE := ministryofjustice/tech-docs-github-pages-publisher:v3 +IMAGE := docker.io/ministryofjustice/tech-docs-github-pages-publisher@sha256:cd3513beca3fcaf5dd34cbe81a33b3ff30337d8ada5869b40a6454c21d6f7684 # v4.0.0 # Use this to run a local instance of the documentation site, while editing -.PHONY: preview check +.PHONY: preview package preview: - docker run --rm \ + docker run --rm --platform=linux/amd64 \ -v $$(pwd)/config:/app/config \ -v $$(pwd)/source:/app/source \ -p 4567:4567 \ - -it $(IMAGE) /scripts/preview.sh + -it $(IMAGE) /usr/local/bin/preview -deploy: - docker run --rm \ +package: + docker run --rm --platform=linux/amd64 \ -v $$(pwd)/config:/app/config \ -v $$(pwd)/source:/app/source \ - -it $(IMAGE) /scripts/deploy.sh - -check: - docker run --rm \ - -v $$(pwd)/config:/app/config \ - -v $$(pwd)/source:/app/source \ - -it $(IMAGE) /scripts/check-url-links.sh + -it $(IMAGE) /usr/local/bin/package