-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
104 lines (97 loc) · 3.72 KB
/
action.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
# action.yml
name: "Convert to RDF"
description: "Converts a structured data source file to Linked Data"
inputs:
global-pattern:
description: "Global pattern that specifies which mapping files should be converted to RDF"
required: true
serialization-format:
description: "Serialization format (nquads (default), turtle, trig, trix, jsonld, hdt)"
required: false
default: "nquads"
output-directory:
description: "Output directory to store Linked Data"
required: true
convert-all:
description: "Convert all data to RDF (false (default), true)"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: "Get all YARRRML filenames"
# create a directory with metadata if it does not exist
# create a directory for the output if it does not exist
# save all filenames (YARRRML) that will be used for conversion
run: |
mkdir -p rml_action_meta
mkdir -p ${{ inputs.output-directory }}
find . -name "${{ inputs.global-pattern }}" -type f | grep -v ".github/workflows" > \
rml_action_meta/filenames.txt
shell: bash
- name: "Setup Node"
uses: actions/setup-node@v2
with:
node-version: "14"
- name: "Get yarrrml-parser"
id: set-node-modules
run: |
NODE_MODULES_PATH=$(npm i -g @rmlio/yarrrml-parser | \
grep -o -m 1 ' -> .*node_modules' | sed 's/ -> //')
echo "::set-output name=NODE_MODULES_PATH::${NODE_MODULES_PATH}"
shell: bash
- name: "Map YARRRML mappings to data source files"
# export NODE_PATH to be able to use yarrrml-parser
# that was installed globally instead of installing it again
run: |
cd ${{ github.action_path }}
export NODE_PATH=${{ steps.set-node-modules.outputs.NODE_MODULES_PATH }}
chmod +x datasource_mapping.js
npm i n-readlines
npm i uuid
npm i yamljs
npm i path
cd ${{ github.workspace }}
node ${{ github.action_path }}/datasource_mapping.js
rm rml_action_meta/filenames.txt
shell: bash
- name: "Check filenames and contents"
# decide whether the action should be fully run or not
# (e.g. there's no need to convert the files if nothing
# was changed)
id: check-contents
run: |
chmod +x ${{ github.action_path }}/check_contents.sh
set +e
${{ github.action_path }}/check_contents.sh
[ $? == 1 ] && RUN_ACTION="true" || RUN_ACTION="false"
set -e
echo "::set-output name=RUN_ACTION::${RUN_ACTION}"
shell: bash
env:
WORKING_DIRECTORY: ${{ github.workspace }}
GLOBAL_PATTERN: ${{ inputs.global-pattern }}
CONVERT_ALL: ${{ inputs.convert-all }}
RUN_ACTION: "false"
- name: "Get rml-mapper"
if: ${{ steps.check-contents.outputs.RUN_ACTION == 'true' }}
run: |
curl -L https://github.com/RMLio/rmlmapper-java/releases/download/v4.12.0/rmlmapper.jar \
--output rmlmapper.jar
shell: bash
- name: "Convert YARRRML rules to RDF for all files"
if: ${{ steps.check-contents.outputs.RUN_ACTION == 'true' }}
# run the "converter.sh"-script to convert YARRRML rules to RDF rules
run: |
chmod +x ${{ github.action_path }}/converter.sh
${{ github.action_path }}/converter.sh
shell: bash
env:
INPUTS_OUTPUT_DIRECTORY: ${{ inputs.output-directory }}
WORKING_DIRECTORY: ${{ github.workspace }}
SERIALIZATION_FORMAT: ${{ inputs.serialization-format }}
CONVERT_ALL: ${{ inputs.convert-all }}
- name: "Remove the rml-mapper jar file"
if: ${{ steps.check-contents.outputs.RUN_ACTION == 'true' }}
run: rm rmlmapper.jar
shell: bash