From eed15fdbd4113ee3e6177a37db0fcb388c853d52 Mon Sep 17 00:00:00 2001 From: Marc Campbell Date: Fri, 8 Feb 2019 07:04:59 -0800 Subject: [PATCH] Update docs, only run on tags --- .github/main.workflow | 2 +- CONTRIBUTING.md | 17 +++++++++++++++++ README.md | 5 +++++ src/commands/scan.ts | 1 - 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/main.workflow b/.github/main.workflow index 5b264f5..b8d63e7 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -19,7 +19,7 @@ action "Build" { action "Publish Filter" { needs = ["Build"] uses = "actions/bin/filter@master" - args = "branch master" + args = "tag" } action "Docker Login" { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6f04057..a6f1f71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,19 @@ # Contributing +Clone this repo, and run + +``` +make test +``` + +To locally run end-to-end tests in a Docker container, and more closely match the GitHub Action environment, you can riun + +``` +make test-docker +``` + +To run locally, without Docker: + ``` $ make build && \ node --no-deprecation ./build/hugo-linkcheck-action.js scan https://www.mysite.com @@ -7,3 +21,6 @@ $ make build && \ # Why is this javascript instead of just bash? +Many GitHub actions are simply an `entrypoint.sh`, intead of code that can be compiled. This is recommended because it's more transparant and often easy to wrap everything in a bash script. For this project, I wanted to use the great work work in the `broken-link-checker` module, but that project is designed to run independently today. The output is not controllable frmo the UI. The original version of this Action used it, and had some rather difficult to grok sed and grep statements to collect the output. In the end, it's much more maintainable as a few lines of javascript, instead of hard-to-read bash. + + diff --git a/README.md b/README.md index 3835f88..fae8380 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Builds a Hugo site and validates that there are no broken links in the site. Any broken links will be reported as a comment on the pull request. +This Action uses the [stevenvachon/broken-link-checker](https://github.com/stevenvachon/broken-link-checker) module to crawl and report broken links. + ### Quick Start Add a new [GitHub Action](https://github.com/features/actions) to your repo. You can create a file named `.github/main.workflow` and use this as a quick start: @@ -21,6 +23,9 @@ action "linkcheck" { uses = "docker://marc/hugo-linkcheck:master" needs = "filter-to-pr-open-synced" secrets = ["GITHUB_TOKEN"] + env = { + HUGO_FINAL_URL = "https://mysite.com" + } } ``` diff --git a/src/commands/scan.ts b/src/commands/scan.ts index 1fe1100..0811bcd 100644 --- a/src/commands/scan.ts +++ b/src/commands/scan.ts @@ -3,7 +3,6 @@ import* as fs from "fs"; import { logger } from "../logger"; import * as blc from "broken-link-checker"; import * as Octokit from "@octokit/rest"; -import { fileURLToPath } from "url"; exports.name = "scan"; exports.describe = "Scan a web site for broken links";