generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (67 loc) · 2.97 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 }}
- name: check for User Pages
id: userpage
run: |
import os
nwo = os.getenv('GITHUB_REPOSITORY')
errmsg = "fastpages does not support User Pages or repo names that end with github.io, please see https://forums.fast.ai/t/fastpages-replacing-main-username-github-io-page-w-fastpages/64316/3 for more details."
assert ".github.io" not in nwo, errmsg
shell: python
- name: Create Issue if User Pages rule is violated
if: steps.userpage.outcome == 'failure'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Error with repository configuration: repo name",
body: 'fastpages does not support User Pages or repo names that end with github.io, please see https://forums.fast.ai/t/fastpages-replacing-main-username-github-io-page-w-fastpages/64316/3 for more details.'
})