Update urlcheck.yml #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: [hrm_test] | |
pull_request: | |
branches: [hrm_test] | |
# release: | |
# types: [published] | |
workflow_dispatch: | |
name: Check for Broken Links | |
jobs: | |
check-links: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Install dependencies | |
run: | | |
install.packages(c("xml2", "rvest", "httr")) | |
- name: Check for Broken Links | |
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)); \ | |
} \ | |
} \ | |
}" |