Skip to content

Commit

Permalink
Update urlcheck.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hillarymarler committed Aug 28, 2024
1 parent 3505669 commit 472e5fa
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/urlcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,25 @@ on:
# types: [published]
workflow_dispatch:

name: Check for Broken Links
name: Check URLs

on: [push, pull_request]

jobs:
check-links:
url-check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up R
uses: r-lib/actions/setup-r@v2

- name: Install dependencies
- name: Install urlchecker
run: |
install.packages(c("xml2", "rvest", "httr"))
Rscript -e 'install.packages("urlchecker", repos="https://cloud.r-project.org")'
- name: Check for Broken Links
- name: Run urlchecker
run: |
Rscript -e "library(xml2); library(rvest); library(httr); \
urls <- c('https://github.com/USEPA/EPATADA/'); \
for (url in urls) { \
page <- read_html(url); \
links <- html_nodes(page, 'a') %>% html_attr('href'); \
for (link in links) { \
res <- GET(link); \
if (status_code(res) >= 400) { \
stop(paste('Broken link:', link)); \
} \
} \
}"
Rscript -e 'urlchecker::url_check(".")'

0 comments on commit 472e5fa

Please sign in to comment.