Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
victoriadrake committed Jul 12, 2020
0 parents commit 8a12a1a
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
env/
venv/
hydra.py
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Container image that runs your code
FROM python:3-buster

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Victoria Drake

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Link Snitch: scan your site for broken links so you can fix them 馃敆

A lightweight GitHub Action that runs [hydra-link-checker](https://github.com/victoriadrake/hydra-link-checker) on the URL you provide, which crawls your site and scans for broken links using multithreaded Python (standard library).

It's up to you to use Link Snitch responsibly!

## Contributing

This project simply Action-ifies (that's a word now, right?) the Hydra program. To submit issues or contributions to the link-checking functionality, go to [hydra-link-checker](https://github.com/victoriadrake/hydra-link-checker).

## Use this in your workflow

You can use this action in a workflow file to run Link Snitch on your choice of trigger, for instance, on a `push` event to the `master` branch:

```yml
push:
branches:
- master
```

Or on a weekly schedule, say, 04:05 on Monday:

```yml
on:
schedule:
- cron: '5 4 * * 1'
```

Here's a full example of a workflow file. See below for `env` instructions.

```yml
name: Link Snitch

on:
push:
branches:
- master

env:
URL: https://example.com
FILENAME: report.yaml

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Check out master
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Report broken links
uses: victoriadrake/link-snitch@master
```

### Setting the `env` variables

This action requires a single environment variable, `URL`. Set this to the fully qualified address of your site, including schema (the `https://` part).

The `FILENAME` variable is optional. See [view results](#view-results) below.

### Workflow customization

See full instructions for [Configuring and managing workflows](https://help.github.com/en/actions/configuring-and-managing-workflows).

For help editing the YAML file, see [Workflow syntax for GitHub Actions](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions).

## View results

By default, the report is YAML formatted and output to `stdout` in your Action run. If you wish to save this to a file that you can download, set `FILENAME` to a file name of your choosing, then use `actions/upload-artifact`. See [Uploading build and test artifacts](https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#uploading-build-and-test-artifacts) for more.
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Link Snitch'
description: 'Scans your site for broken links so you can fix them.'
author: 'victoriadrake'
branding:
icon: 'link'
color: 'yellow'
runs:
using: 'docker'
image: 'Dockerfile'
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -eo pipefail

curl -sSL https://raw.githubusercontent.com/victoriadrake/hydra-link-checker/master/hydra.py > hydra.py

if grep -q "404: Not Found" hydra.py; then
echo -e "Couldn't get link checking program. Is victoriadrake/hydra-link-checker available?"
exit 1
fi

if [[ -z "${URL}" ]]; then
echo -e "No URL set."
fi

if ! [[ -z "${URL}" ]] && [[ -z "${FILENAME}" ]]; then
time python3 hydra.py ${URL}
fi

if ! [[ -z "${URL}" ]] && ! [[ -z "${FILENAME}" ]]; then
time python3 hydra.py ${URL} > ${FILENAME}
fi

0 comments on commit 8a12a1a

Please sign in to comment.