forked from sciml-leeds/sciml-leeds.github.io
-
Notifications
You must be signed in to change notification settings - Fork 31
56 lines (47 loc) · 1.95 KB
/
check_config.yaml
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
name: Check Configurations
on: push
jobs:
check-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install dependencies
run: pip3 install pyyaml
- name: check baseurl
id: baseurl
run: |
import yaml
from pathlib import Path
from configparser import ConfigParser
settings = ConfigParser()
config_path = Path('_config.yml')
settings_path = Path('_action_files/settings.ini')
assert config_path.exists(), 'Did not find _config.yml in the current directory!'
assert settings_path.exists(), 'Did not find _action_files/settings.ini in the current directory!'
settings.read(settings_path)
with open('_config.yml') as f:
config = yaml.safe_load(f)
errmsg = f"The value set for baseurl in _action_files/settings.ini and _config.yml are not identical. Please fix and try again."
assert config['baseurl'] == settings['DEFAULT']['baseurl'], errmsg
shell: python
- name: Create issue if baseurl rule is violated
if: steps.baseurl.outcome == 'failure'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var err = process.env.ERROR_STRING;
var run_id = process.env.RUN_ID;
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Error with repository configuration: baseurl",
body: `${err}\n See run [${run_id}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}) for more details.`
})
env:
ERROR_STRING: "You have not configured your baseurl correctly, please read the instructions in _config.yml carefully."
RUN_ID: ${{ github.run_id }}