|
1 |
| -name: Update Products |
| 1 | +name: Update Lookup Tables |
2 | 2 | on:
|
3 | 3 | workflow_dispatch:
|
4 | 4 | inputs:
|
|
14 | 14 | # branches:
|
15 | 15 | # - master
|
16 | 16 | jobs:
|
17 |
| - update_products: |
| 17 | + update_tables: |
18 | 18 | runs-on: ubuntu-latest
|
19 | 19 | steps:
|
20 | 20 | - uses: actions/checkout@v2
|
21 | 21 | with:
|
22 | 22 | persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
|
23 | 23 | fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
|
24 | 24 |
|
| 25 | + - name: Install Perl dependencies |
| 26 | + run: | |
| 27 | + sudo apt install cpanminus |
| 28 | + cpanm Text::CSV |
| 29 | + |
25 | 30 | - name: Download and Build Products Table
|
26 | 31 | run: |
|
27 |
| - cd products |
28 |
| - echo 'DELETE FROM "product";' > ./product.sql.new |
29 |
| - echo 'COPY "product" ("oid", "mib", "leaf", "description") FROM STDIN;' >> ./product.sql.new |
| 32 | + export TARGET="products/product.sql" |
| 33 | + echo 'DELETE FROM "product";' > ${TARGET}.new |
| 34 | + echo 'COPY "product" ("oid", "mib", "leaf", "description") FROM STDIN;' >> ${TARGET}.new |
30 | 35 | curl --silent --location "https://mibbrowser.online/mibdb_search.php?all=1" | \
|
31 | 36 | grep JUNIPER-CHASSIS-DEFINES | \
|
32 | 37 | grep -o 'mib=[^"]\+' | \
|
33 | 38 | sed -e 's/mib=//' | \
|
34 | 39 | grep -hi -E '(product|oid|JUNIPER-CHASSIS-DEFINES)' | \
|
35 | 40 | while read mib; do \
|
36 | 41 | curl --silent --location "https://mibbrowser.online/mibs_json/$mib.json" | \
|
37 |
| - ./pysmi-json-to-products-table.py >> ./product.sql.new; \ |
| 42 | + products/pysmi-json-to-products-table.py >> ${TARGET}.new; \ |
38 | 43 | done
|
39 |
| - echo '\.' >> ./product.sql.new |
40 |
| - echo '' >> ./product.sql.new |
41 |
| - echo '' >> ./product.sql.new |
42 |
| - mv ./product.sql.new ./product.sql |
| 44 | + echo '\.' >> ${TARGET}.new |
| 45 | + mv ${TARGET}.new ${TARGET} |
43 | 46 |
|
| 47 | + - name: Download and Build Enterprises Table |
| 48 | + run: | |
| 49 | + export TARGET="ieee/SMI/enterprise.sql" |
| 50 | + echo 'DELETE FROM "enterprise";' > ${TARGET}.new |
| 51 | + echo 'COPY "enterprise" ("enterprise_number", "organization") FROM STDIN;' >> ${TARGET}.new |
| 52 | + curl --silent --location "https://www.iana.org/assignments/enterprise-numbers.txt" | \ |
| 53 | + ieee/SMI/smi-to-enterprise-table.py >> ${TARGET}.new |
| 54 | + echo '\.' >> ${TARGET}.new |
| 55 | + mv ${TARGET}.new ${TARGET} |
| 56 | + |
44 | 57 | - name: Commit files
|
45 | 58 | run: |
|
46 | 59 | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
0 commit comments