-
Notifications
You must be signed in to change notification settings - Fork 32
63 lines (54 loc) · 2.17 KB
/
Copy pathdata-refresh.yml
File metadata and controls
63 lines (54 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Refresh dataset
# Regenerates lib/sepomex_db.csv from the latest official SEPOMEX export and
# opens a PR when the data changes.
#
# The scheduled run is self-contained: `rake data:refresh` downloads the export
# straight from Correos de México (the CodigoPostal_Exportar.aspx WebForms
# postback, handled by FetchSepomexExport) and regenerates the CSV — no mirror
# URL to provision. Pass a `xml_url` on manual dispatch to import a specific,
# already-hosted `CPdescarga.xml` instead (e.g. to reproduce a past export).
on:
workflow_dispatch:
inputs:
xml_url:
description: Optional URL to a specific SEPOMEX CPdescarga.xml (skips the live download)
required: false
schedule:
- cron: "0 6 1 * *" # 06:00 UTC on the 1st of each month
permissions:
contents: write
pull-requests: write
concurrency:
group: data-refresh
cancel-in-progress: false
jobs:
refresh:
name: Refresh dataset
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Regenerate lib/sepomex_db.csv from the latest export
if: github.event.inputs.xml_url == ''
run: bundle exec rake data:refresh
- name: Regenerate lib/sepomex_db.csv from a provided URL
if: github.event.inputs.xml_url != ''
run: |
curl -fSL "${{ github.event.inputs.xml_url }}" -o "${RUNNER_TEMP}/CPdescarga.xml"
bundle exec rake "data:import_xml[${RUNNER_TEMP}/CPdescarga.xml]"
- name: Open a PR if the dataset changed
uses: peter-evans/create-pull-request@v8
with:
branch: chore/refresh-dataset
add-paths: lib/sepomex_db.csv
commit-message: Refresh lib/sepomex_db.csv from the latest SEPOMEX export
title: Refresh postal-code dataset
labels: data
body: |
Automated refresh of `lib/sepomex_db.csv` from the latest official
SEPOMEX export (`rake data:refresh`).
After merging, the next release image bakes in the new data; to update
a running/local database, run `bin/rails db:reset && rake data:loadev`.