-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
192 lines (172 loc) · 6.01 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Build Ecosystem Website
description: 'Builds the Ecosystem Website'
author: 'Enrico Daga'
inputs:
repositories:
description: 'The file listing the repositories to be included in the Ecosystem Website'
required: true
repository:
description: 'The Github repository running the action'
default: ${{ github.repository }}
on: [push]
runs:
using: "composite"
steps:
- name: message-log
id: print-welcome-log
run: echo "Making ${{ inputs.repository }} a Research Ecosystem"
shell: bash
- name: checkout repo content
uses: actions/checkout@v3
- name: setup github user
shell: bash
run: |
git config --global user.email ${GITHUB_ACTOR}@users.noreply.github.com
git config --global user.name ${GITHUB_ACTOR}
- name: check if repositories.txt exists in this repo
id: check_files
uses: andstor/file-existence-action@v2
with:
files: ${{ inputs.repositories }}
- name: repositories.txt does not exist, check if an issue already exists
if: steps.check_files.outputs.files_exists == 'false'
uses: nickderobertis/check-if-issue-exists-action@master
id: check_if_issue_exists
with:
repo: "${{ github.event.repository.name }}"
token: ${GITHUB_TOKEN}
title: missing repositories.txt
labels: bug
- name: repositories.txt and issue do not exist, create an issue
if: steps.check_files.outputs.files_exists == 'false' && steps.check_if_issue_exists.outputs.exists == 'false'
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
filename: initialize-issue-text.md
- name: issue created, early exit
shell: bash
if: steps.check_files.outputs.files_exists == 'false' && steps.check_if_issue_exists.outputs.exists == 'false'
run: # exit_with_success
- name: repositories.txt exists, read and update submodules
if: steps.check_files.outputs.files_exists == 'true'
id: split_repos
shell: bash
env:
ACCESS_TOKEN: ${GITHUB_TOKEN}
run: |
git rm -r --ignore-unmatch content
while IFS= read -r line; do
IN="$line"
[ -z "$line" ] && continue
arrIN=(${IN//:/ })
repo=${arrIN[0]}
version=${arrIN[2]}
echo "repo: $repo version: $version"
rm -rf "content/_$repo"
git clone -n "https://github.com/$repo" "content/_$repo"
cd "content/_$repo"
git ls-tree -r "$version" --full-tree --name-only | grep "\.md" > files.tmp
while IFS= read -r line; do
git checkout "$version" "$line" || echo "WARNING: error checking out $line"
sed -i 's#{{#{% raw %}{{{% endraw %}#g' "$line" || echo ""
done < files.tmp
rm files.tmp
rm -rf .git
rm -rf .github
cd -
done < ${{ inputs.repositories }}
- name: generate repositories data
if: steps.check_files.outputs.files_exists == 'true'
id: generate-repositories-data
shell: bash
run: |
rm -f _data/repositories.yml
while IFS= read -r line; do
[ -z "$line" ] && continue
#
IN="$line"
arrIN=(${IN//:/ })
repo=${arrIN[0]}
treetype=${arrIN[1]}
version=${arrIN[2]}
echo "Generate repo data: $line"
echo "- repo: \"$repo\"" >> _data/repositories.yml
echo " type: \"$treetype\"" >> _data/repositories.yml
echo " version: \"$version\"" >> _data/repositories.yml
echo " url: \"http://github.com/$repo\"" >> _data/repositories.yml
echo " link: \"http://github.com/$repo/blob/$version/\"" >> _data/repositories.yml
echo " raw_link: \"https://raw.githubusercontent.com/$repo/$version/\"" >> _data/repositories.yml
done < ${{ inputs.repositories }}
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: install python packages
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r ${{ github.action_path }}/requirements.txt
- name: validate yaml headings in md files
shell: bash
id: validate_yml
run: |
rm -f _data/validation.yml
python ${{ github.action_path }}/validate.py
- name: build RDF data files
id: build_rdf_data_files
shell: bash
run: |
pip install pysparql-anything
python ${{ github.action_path }}/build_rdf_data_files.py
- name: build Citation data CSV
id: build_citation_data_file
shell: bash
run: |
rm -f _data/cite.yml
pip install pysparql-anything
python ${{ github.action_path }}/build_citation_data_file.py
- name: get current date
shell: bash
id: date
run: echo "name=date::$(date +'%Y_%m_%d_%H-%M')" >> $GITHUB_OUTPUT
- name: commit and push report
uses: Andro999b/[email protected]
with:
github_token: ${{ github.token }}
shell: bash
branch: main
force: true
message: new report - ${{ steps.date.outputs.date }}
- name: check releases, zenodo sync, write report, PR zenodo.json to repos
id: releases_zenodo
shell: bash
run: python ${{ github.action_path }}/releases_zenodo.py
env:
TOKEN: ${{ github.token }}
- name: write release report file
uses: "DamianReeves/write-file-action@master"
with:
path: releases/${{ steps.date.outputs.date }}_report.json
write-mode: overwrite
contents: ${{ steps.releases_zenodo.outputs.releases_report }}
- name: commit and push report
uses: Andro999b/[email protected]
with:
github_token: ${{ github.token }}
branch: main
force: true
shell: bash
message: new release report - ${{ steps.date.outputs.date }}
#- name: transform valid data and releases to RDF and store
# todo
# - name: setup python
# uses: actions/setup-python@v4
# with:
# python-version: '3.9' # install the python version needed
# - name: install python packages
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# - name: execute py script # run main.py
# run: python initialize.py