-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (156 loc) · 5.61 KB
/
ci.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
name: Continuous integration and deployment
on:
push:
schedule:
- cron: '0 0 * * 0' # weekly
workflow_dispatch:
jobs:
testExamples:
name: Test example SED-ML files (in COMBINE archives)
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('site_creator/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
- name: Install requirements
run: python -m pip install -r tests/requirements.txt
- name: Compile example COMBINE archives
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends zipcmp
python scripts/compile_examples_combine_archives.py
- name: Test examples
run: python -m pytest tests/
compileStaticWebsite:
name: Compile static website
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: testExamples
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('site_creator/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
- name: Install requirements
working-directory: site_creator
run: python -m pip install -r requirements.txt
- name: Setup Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "SED-ML Bot"
git config pull.rebase false
- name: Compile website
working-directory: site_creator
run: python create_static_html.py
- id: commit-compiled-website
name: Commit changes to the compiled web pages
run: |
git stash
git pull
set +e
git stash pop
git add *.html
git commit -m "Updated compiled files for website [skip ci]"
if [[ $? = 0 ]]; then
websiteChanged=1
else
websiteChanged=0
fi
echo "::set-output name=websiteChanged::$websiteChanged"
- name: Compile example COMBINE archives
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends zipcmp
python scripts/compile_examples_combine_archives.py
- id: commit-example-combine-archives
name: Commit compiled example COMBINE archives
run: |
git stash
git pull
set +e
git stash pop
git add examples/*.omex
git commit -m "Updated example COMBINE archives [skip ci]"
if [[ $? = 0 ]]; then
examplesChanged=1
else
examplesChanged=0
fi
echo "::set-output name=examplesChanged::$examplesChanged"
- name: Bundle examples
id: bundle-examples
working-directory: examples/L1V3
run: |
zip SED-ML_L1V3_examples-new.zip *.omex
zipcmp SED-ML_L1V3_examples.zip SED-ML_L1V3_examples-new.zip
if [[ $? = 0 ]]; then
changed=0
rm SED-ML_L1V3_examples-new.zip
else
changed=1
mv SED-ML_L1V3_examples-new.zip SED-ML_L1V3_examples.zip
fi
echo "::set-output name=changed::$changed"
- id: commit-bundled-examples
if: steps.bundle-examples.outputs.changed == '1'
name: Commit changes to the bundled examples
working-directory: examples/L1V3
run: |
git stash
git pull
set +e
git stash pop
git add SED-ML_L1V3_examples.zip
git commit -m "Updated bundle of example files [skip ci]"
- name: Determine branch to push compiled website to
id: get-push-branch
run: |
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
echo "::set-output name=branch::ci-compiled-website"
else
echo "::set-output name=branch::${{ github.ref }}"
fi
- name: Push the changes to the compiled website
if: steps.commit-compiled-website.outputs.websiteChanged == '1' || steps.commit-example-combine-archives.outputs.examplesChanged == '1' || steps.bundle-examples.outputs.changed == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.get-push-branch.outputs.branch }}
force: ${{ steps.get-push-branch.outputs.branch == 'ci-compiled-website' }}
- name: Create pull request
if: steps.get-push-branch.outputs.branch == 'ci-compiled-website'
uses: peter-evans/create-pull-request@v3
with:
branch: ${{ steps.get-push-branch.outputs.branch }}