Skip to content

Commit

Permalink
Add action & readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wpears committed Feb 27, 2024
1 parent 96bd3ea commit d6d0183
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/save-regs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Save regs

on:
workflow_dispatch:

env:
PARTS: (1003)

jobs:
save-regs:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Installs htmlq
uses: baptiste0928/[email protected]
with:
crate: htmlq
version: "0.4.0"

- name: Find latest date
id: date
uses: sergeysova/jq-action@a3f0d4ff59cc1dddf023fc0b325dd75b10deec58
with:
cmd: "curl -sSL https://www.ecfr.gov/api/versioner/v1/titles.json | jq '.titles[] | select(.number == 12) | .up_to_date_as_of'"

- name: Fetch and extract parts from eCFR
run: |
for PART in "${PARTS[@]}"; do
curl -sSL "https://www.ecfr.gov/api/renderer/v1/content/enhanced/${DATE}/title-12?chapter=X&part=${PART}" | htmlq -t '.part' | sed '/^$/d' > "./parts/${{ steps.date.outputs.value }}.txt"
done
- name: Test output
run: ls -l parts

- name: Show output
run: cat ./parts/1003.txt
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Title 12 Chapter X as text
Data pulled from [eCFR](https://www.ecfr.gov/current/title-12/chapter-X)

0 comments on commit d6d0183

Please sign in to comment.