Skip to content

Commit a9c647b

Browse files
committed
Initial commit
0 parents  commit a9c647b

File tree

136 files changed

+7961
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+7961
-0
lines changed

.devcontainer.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "fastpages-codespaces",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "watcher",
5+
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
6+
"forwardPorts": [4000, 8080],
7+
"appPort": [4000, 8080],
8+
"extensions": ["ms-python.python",
9+
"ms-azuretools.vscode-docker"],
10+
"runServices": ["converter", "notebook", "jekyll", "watcher"]
11+
}
12+

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto

.github/ISSUE_TEMPLATE/bug.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Bug
3+
about: Use this template for filing bugs
4+
title: ""
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
## Required Prerequisites for filing a bug
11+
12+
### You must follow ALL the steps in the [troubleshooting guide](https://github.com/fastai/fastpages/blob/master/_fastpages_docs/TROUBLESHOOTING.md). Not doing so may result in automatic closure of the issue.
13+
14+
15+
## Required information
16+
17+
1. Steps to reproduce the problem
18+
2. A link to the notebook or markdown file where the error is occurring
19+
3. If the error is happening in GitHub Actions, a link to the specific error along with how you are able to reproduce this error. You must provide this **in addition to the link to the notebook or markdown file**.
20+
4. A screenshot / dump of relevant logs or error messages you are receiving from your local development environment. Instructions of running a local development server is provided in the [development guide](https://github.com/fastai/fastpages/blob/master/_fastpages_docs/DEVELOPMENT.md).
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/upgrade.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: "[fastpages] Automated Upgrade"
3+
about: "Trigger a PR for upgrading fastpages"
4+
title: "[fastpages] Automated Upgrade"
5+
labels: fastpages-automation
6+
assignees: ''
7+
8+
---
9+
10+
Opening this issue will trigger GitHub Actions to fetch the latest version of [fastpages](https://github.com/fastai/fastpages). More information will be provided in forthcoming comments below.

.github/workflows/chatops.yaml

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Chatops
2+
on: [issue_comment]
3+
4+
jobs:
5+
trigger-chatops:
6+
if: (github.event.issue.pull_request != null) && contains(github.event.comment.body, '/preview') && (github.repository == 'fastai/fastpages')
7+
env:
8+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
9+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
10+
CHECK_RUN_NAME: "Draft-Site-Build"
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: see payload
15+
run: |
16+
echo "FULL PAYLOAD:\n${PAYLOAD}\n"
17+
echo "PR_PAYLOAD PAYLOAD:\n${PR_PAYLOAD}"
18+
env:
19+
PAYLOAD: ${{ toJSON(github.event) }}
20+
PR_PAYLOAD: ${{ github.event.pull_request }}
21+
22+
- name: verify env exists
23+
id: get_status
24+
run: |
25+
if [ -z ${NETLIFY_AUTH_TOKEN} ]; then echo "::set-output name=status::public"; else echo "::set-output name=status::private"; fi
26+
27+
- name: make comment on PR if env does not exist
28+
if: steps.get_status.outputs.status == 'public'
29+
run: |
30+
./_action_files/pr_comment.sh "Was not able to generate site preview due to absent credentials."
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
ISSUE_NUMBER: ${{ github.event.issue.number }}
34+
35+
- name: Fetch context about the PR that has been commented on
36+
id: chatops
37+
uses: machine-learning-apps/actions-chatops@master
38+
with:
39+
TRIGGER_PHRASE: "/preview"
40+
env: # you must supply GITHUB_TOKEN
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Set up Python
44+
uses: actions/setup-python@v1
45+
with:
46+
python-version: 3.6
47+
48+
- name: install requests
49+
run: pip3 install requests
50+
51+
- name: add check run
52+
id: create_check
53+
if: steps.get_status.outputs.status == 'private'
54+
shell: python
55+
run: |
56+
import os, requests
57+
58+
sha = os.getenv('SHA')
59+
token = os.getenv('GITHUB_TOKEN')
60+
nwo = os.getenv('GITHUB_REPOSITORY')
61+
name = os.getenv('CHECK_RUN_NAME')
62+
63+
url = f'https://api.github.com/repos/{nwo}/check-runs'
64+
65+
headers = {'authorization': f'token {token}',
66+
'accept': 'application/vnd.github.antiope-preview+json'}
67+
68+
payload = {
69+
'name': f'{name}',
70+
'head_sha': f'{sha}',
71+
'status': 'in_progress',
72+
'output':{
73+
'title': f'Building preview of site for {sha}.',
74+
'summary': ' ',
75+
'text': ' '
76+
},
77+
}
78+
response = requests.post(url=url, headers=headers, json=payload)
79+
print(response)
80+
id = response.json()['id']
81+
print(f"::set-output name=id::{id}")
82+
env:
83+
SHA: ${{ steps.chatops.outputs.SHA }}
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: add label
87+
if: steps.get_status.outputs.status == 'private'
88+
run: |
89+
import os, requests
90+
nwo = os.getenv('GITHUB_REPOSITORY')
91+
token = os.getenv('GITHUB_TOKEN')
92+
pr_num = os.getenv('PR_NUM')
93+
headers = {'Accept': 'application/vnd.github.symmetra-preview+json',
94+
'Authorization': f'token {token}'}
95+
url = f"https://api.github.com/repos/{nwo}/issues/{pr_num}/labels"
96+
data = {"labels": ["draft build pending"]}
97+
result = requests.post(url=url, headers=headers, json=data)
98+
# assert response.status_code == 201, f"Received status code of {response.status_code}"
99+
print(result)
100+
shell: python
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
PR_NUM: ${{ steps.chatops.outputs.PULL_REQUEST_NUMBER }}
104+
GITHUB_REPOSITORY: $GITHUB_REPOSITORY
105+
106+
- name: Copy The PR's Branch Repository Contents
107+
uses: actions/checkout@main
108+
if: steps.get_status.outputs.status == 'private'
109+
with:
110+
ref: ${{ steps.chatops.outputs.SHA }}
111+
112+
- name: convert notebooks and word docs to posts
113+
uses: ./ # use the code in this repo to instead of fastai/fastpages@master
114+
115+
- name: setup directories for Jekyll build
116+
if: steps.get_status.outputs.status == 'private'
117+
run: |
118+
rm -rf _site
119+
sudo chmod -R 777 .
120+
121+
- name: Jekyll build with baseurl as root for netifly
122+
if: steps.get_status.outputs.status == 'private'
123+
uses: docker://fastai/fastpages-jekyll
124+
with:
125+
args: bash -c "jekyll build"
126+
127+
- name: deploy to netlify
128+
if: steps.get_status.outputs.status == 'private'
129+
id: py
130+
run: |
131+
sudo npm install -g --unsafe-perm=true netlify-cli
132+
netlify deploy --dir _site | tee _netlify_logs.txt
133+
cat _netlify_logs.txt | python _action_files/parse_netlify.py
134+
135+
- name: make comment on PR
136+
if: steps.get_status.outputs.status == 'private'
137+
run: |
138+
MSG="A preview build of this branch has been generated for SHA: $SHA and can be viewed **live** at: ${URL}\n\nThe current fastpages site built from master can be viewed for comparison [here](https://fastpages.fast.ai/)"
139+
echo "$MSG"
140+
./_action_files/pr_comment.sh "${MSG}"
141+
env:
142+
URL: ${{ steps.py.outputs.draft_url }}
143+
SHA: ${{ steps.chatops.outputs.SHA }}
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
ISSUE_NUMBER: ${{ github.event.issue.number }}
146+
147+
- name: remove label
148+
if: always()
149+
run: |
150+
import os, requests
151+
nwo = os.getenv('GITHUB_REPOSITORY')
152+
token = os.getenv('GITHUB_TOKEN')
153+
pr_num = os.getenv('PR_NUM')
154+
headers = {'Accept': 'application/vnd.github.symmetra-preview+json',
155+
'Authorization': f'token {token}'}
156+
url = f"https://api.github.com/repos/{nwo}/issues/{pr_num}/labels/draft%20build%20pending"
157+
result = requests.delete(url=url, headers=headers)
158+
print(result)
159+
shell: python
160+
env:
161+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162+
PR_NUM: ${{ steps.chatops.outputs.PULL_REQUEST_NUMBER }}
163+
GITHUB_REPOSITORY: $GITHUB_REPOSITORY
164+
165+
# defensively clear check run each time
166+
- name: clear check run
167+
if: always()
168+
continue-on-error: true
169+
shell: python
170+
run: |
171+
import os, requests
172+
173+
sha = os.getenv('SHA')
174+
conclusion = os.getenv('WORKFLOW_CONCLUSION').lower()
175+
token = os.getenv('GITHUB_TOKEN')
176+
nwo = os.getenv('GITHUB_REPOSITORY')
177+
check_run_id = os.getenv('CHECK_RUN_ID')
178+
if not check_run_id:
179+
quit()
180+
181+
url = f'https://api.github.com/repos/{nwo}/check-runs/{check_run_id}'
182+
headers = {'authorization': f'token {token}',
183+
'accept': 'application/vnd.github.antiope-preview+json'}
184+
185+
data = {
186+
'conclusion': f'{conclusion}',
187+
}
188+
response = requests.patch(url=url, headers=headers, json=data)
189+
print(response)
190+
env:
191+
SHA: ${{ steps.chatops.outputs.SHA }}
192+
WORKFLOW_CONCLUSION: ${{ job.status }}
193+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
CHECK_RUN_ID: ${{ steps.create_check.outputs.id }}
195+

.github/workflows/check_cdns.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Check CDN
2+
on:
3+
# push:
4+
# schedule:
5+
# - cron: '1 7,14,21 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@main
13+
- run: ./_action_files/check_js.sh

.github/workflows/check_config.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Check Configurations
2+
on: push
3+
4+
jobs:
5+
check-config:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@main
9+
10+
- name: Set up Python
11+
uses: actions/setup-python@v1
12+
with:
13+
python-version: 3.7
14+
15+
- name: install dependencies
16+
run: pip3 install pyyaml
17+
18+
- name: check baseurl
19+
id: baseurl
20+
run: |
21+
import yaml
22+
from pathlib import Path
23+
from configparser import ConfigParser
24+
settings = ConfigParser()
25+
26+
config_path = Path('_config.yml')
27+
settings_path = Path('_action_files/settings.ini')
28+
29+
assert config_path.exists(), 'Did not find _config.yml in the current directory!'
30+
assert settings_path.exists(), 'Did not find _action_files/settings.ini in the current directory!'
31+
32+
settings.read(settings_path)
33+
with open('_config.yml') as f:
34+
config = yaml.safe_load(f)
35+
36+
errmsg = f"The value set for baseurl in _action_files/settings.ini and _config.yml are not identical. Please fix and try again."
37+
assert config['baseurl'] == settings['DEFAULT']['baseurl'], errmsg
38+
shell: python
39+
40+
- name: Create issue if baseurl rule is violated
41+
if: steps.baseurl.outcome == 'failure'
42+
uses: actions/[email protected]
43+
with:
44+
github-token: ${{secrets.GITHUB_TOKEN}}
45+
script: |
46+
var err = process.env.ERROR_STRING;
47+
var run_id = process.env.RUN_ID;
48+
github.issues.create({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
title: "Error with repository configuration: baseurl",
52+
body: `${err}\n See run [${run_id}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}) for more details.`
53+
})
54+
env:
55+
ERROR_STRING: "You have not configured your baseurl correctly, please read the instructions in _config.yml carefully."
56+
RUN_ID: ${{ github.run_id }}
57+
58+
- name: check for User Pages
59+
id: userpage
60+
run: |
61+
import os
62+
nwo = os.getenv('GITHUB_REPOSITORY')
63+
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."
64+
assert ".github.io" not in nwo, errmsg
65+
shell: python
66+
67+
- name: Create Issue if User Pages rule is violated
68+
if: steps.userpage.outcome == 'failure'
69+
uses: actions/[email protected]
70+
with:
71+
github-token: ${{secrets.GITHUB_TOKEN}}
72+
script: |
73+
github.issues.create({
74+
owner: context.repo.owner,
75+
repo: context.repo.repo,
76+
title: "Error with repository configuration: repo name",
77+
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.'
78+
})

0 commit comments

Comments
 (0)