diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..dd792d4 --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,8 @@ +workflow "New workflow" { + on = "push" + resolves = ["markdown-link-check"] +} + +action "markdown-link-check" { + uses = "./" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..19e061d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:3.8 +RUN apk add --no-cache bash nodejs npm +LABEL "com.github.actions.name"="markdown-link-check" +LABEL "com.github.actions.description"="Check if all links are valid in markdown files." +LABEL "com.github.actions.icon"="link" +LABEL "com.github.actions.color"="green" +LABEL "repository"="https://github.com/gaurav-nelson/github-action-markdown-link-check.git" +LABEL "homepage"="https://github.com/gaurav-nelson/github-action-markdown-link-check" +LABEL "maintainer"="Gaurav Nelson" +ADD entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index d346a0f..4ec060d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# github-action-markdown-link-check -Check all links in markdown files if they are alive or dead. +# GitHub Action - Markdown link check 🔗✔️ +This GitHub action checks all Markdown files in your repository for broken links. (Uses [tcort/markdown-link-check](https://github.com/tcort/markdown-link-check)) + +## Sample workflow +``` +workflow "New workflow" { + on = "push" + resolves = ["markdown-link-check"] +} + +action "markdown-link-check" { + uses = "./" +} +``` + +## Test links + +www.google.com + +[This is a broken link](www.exampleexample.cox) diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..23f827f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -eu + +npm i -g markdown-link-check + +echo "=========================> MARKDOWN LINK CHECK <=========================" + +find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt + +echo "=========================================================================" + +if [ -e error.txt ] ; then + if grep -q "ERROR:" error.txt; then + exit 113 + fi +fi