-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (107 loc) · 4.3 KB
/
package.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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:
- loc232csv
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 classes/${{github.event.inputs.directory}}
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.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: runn diff
working-directory: vocab/
run: |
curl -o unlocode-main.jsonld https://raw.githubusercontent.com/uncefact/vocabulary-outputs/main/unlocode.jsonld && echo "Downloaded"
diff <(jq --sort-keys . unlocode-main.jsonld) <(jq --sort-keys . unlocode.jsonld) > unlocode-diff.txt && echo "Diff created"
curl -o unlocode-subdivisions-main.jsonld https://raw.githubusercontent.com/uncefact/vocabulary-outputs/main/unlocode-subdivisions.jsonld && echo "Downloaded"
diff <(jq --sort-keys . unlocode-subdivisions-main.jsonld) <(jq --sort-keys . unlocode-subdivisions.jsonld) > unlocode-subdivisions-diff.txt && echo "Diff created"
rm unlocode-main.jsonld && echo "File removed"
rm unlocode-subdivisions-main.jsonld && echo "File removed"
- 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