JSON-LD vocabulary generation from CSV files #30
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
name: JSON-LD vocabulary generation from CSV files | |
on: | |
pull_request: | |
paths: | |
- 'scripts/src/**' | |
- 'locodes/**' | |
# Manually run the generation or split | |
workflow_dispatch: | |
inputs: | |
mode: | |
type: choice | |
description: 'The mode of the transformation to run' | |
required: true | |
options: | |
- split | |
- json-ld | |
directory: | |
type: choice | |
description: 'The location of input csv files to be split' | |
required: false | |
options: | |
- loc221csv | |
- loc222csv | |
jobs: | |
json-ld: | |
if: contains(github.event.inputs.mode, 'json-ld') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: package | |
working-directory: scripts/ | |
run: | | |
mvn -B package --file pom.xml | |
- name: copy locodes | |
run: | | |
mkdir scripts/target/csv | |
cp locodes/*.csv scripts/target/csv | |
- name: generate | |
working-directory: scripts/target/ | |
run: | | |
java -jar "$(find -name *.jar)" -t json-ld -d csv | |
jq --sort-keys . unlocode-countries.jsonld > unlocode-countries-sorted.jsonld | |
mv unlocode-countries-sorted.jsonld unlocode-countries.jsonld | |
jq --sort-keys . unlocode-functions.jsonld > unlocode-functions-sorted.jsonld | |
mv unlocode-functions-sorted.jsonld unlocode-functions.jsonld | |
jq --sort-keys . unlocode-subdivisions.jsonld > unlocode-subdivisions-sorted.jsonld | |
mv unlocode-subdivisions-sorted.jsonld unlocode-subdivisions.jsonld | |
jq --sort-keys . unlocode-vocab-context.jsonld > unlocode-vocab-context-sorted.jsonld | |
mv unlocode-vocab-context-sorted.jsonld unlocode-vocab-context.jsonld | |
jq --sort-keys . unlocode-vocab.jsonld > unlocode-vocab-sorted.jsonld | |
mv unlocode-vocab-sorted.jsonld unlocode-vocab.jsonld | |
jq -c --sort-keys . unlocode.jsonld > unlocode-sorted.jsonld | |
mv unlocode-sorted.jsonld unlocode.jsonld | |
mv *.jsonld ../../vocab/ | |
- name: commit json-ld | |
working-directory: vocab/ | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "update UN/LOCODE vocabulary" | |
git push | |
split: | |
if: contains(github.event.inputs.mode, 'split') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
- name: package | |
working-directory: scripts/ | |
run: | | |
mvn -B package --file pom.xml | |
- name: upload transformer | |
uses: actions/upload-artifact@v2 | |
with: | |
name: unlocode-transformer | |
path: scripts/target/unlocode-transformer-*.jar | |
- name: split locodes | |
working-directory: scripts/target | |
run: | | |
java -jar "$(find -name *.jar)" -t split -d classes/${{github.event.inputs.directory}} | |
mv *.csv ../../locodes/ | |
- name: commit locodes | |
working-directory: locodes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "update UN/LOCODE files" | |
git push |