Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.

Commit 4763979

Browse files
author
Hamel Husain
committed
Initial commit
0 parents  commit 4763979

File tree

103 files changed

+5412
-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.

103 files changed

+5412
-0
lines changed

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Bug
3+
about: Use this template for filing bugs
4+
title: "[DATE]: [FEATURE NAME]"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
## Required Prerequisites for filing a bug
11+
12+
#### You must check both boxes
13+
14+
- [ ] Have you searched opened / closed issues on this repo for a similar problem?
15+
- [ ] Have you searched the [fastai forums](https://forums.fast.ai/) for a similar problem?
16+
17+
18+
## Required information
19+
20+
#### Failure to provide this information or going through these steps will result in automatic closing of the issue
21+
22+
1. Steps to reproduce the problem
23+
2. A link to the notebook or markdown file where the error is occuring
24+
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**.
25+
4. This will help expedite troubleshooting: the A screenshot / dump of relevant logs or error messages you are receiving from your local development environment. the local development server as indicated in the [development guide (https://github.com/fastai/fastpages/blob/master/_fastpages_docs/DEVELOPMENT.md)?
Lines changed: 20 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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 lastest version of [fastpages](https://github.com/fastai/fastpages). More information will be provided in forthcoming comments below.

.github/workflows/chatops.yaml

Lines changed: 195 additions & 0 deletions
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@master
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://hamelsmu/fastpages-jekyll
124+
with:
125+
args: bash -c "gem install bundler && 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 netlify-cli -g
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/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master # need to filter here so we only deploy when there is a push to master
6+
# no filters on pull requests, so intentionally left blank
7+
pull_request:
8+
9+
jobs:
10+
build-site:
11+
if: ( github.event.commits[0].message != 'Initial commit' ) || github.run_number > 1
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Copy Repository Contents
16+
uses: actions/checkout@master
17+
with:
18+
persist-credentials: false
19+
20+
- name: convert notebooks and word docs to posts
21+
uses: ./_action_files
22+
23+
- name: setup directories for Jekyll build
24+
run: |
25+
rm -rf _site
26+
sudo chmod -R 777 .
27+
28+
- name: Jekyll build
29+
uses: docker://hamelsmu/fastpages-jekyll
30+
with:
31+
args: bash -c "gem install bundler && jekyll build -V"
32+
env:
33+
JEKYLL_ENV: 'production'
34+
35+
- name: copy CNAME file into _site if CNAME exists
36+
run: |
37+
sudo chmod -R 777 _site/
38+
cp CNAME _site/ 2>/dev/null || :
39+
40+
- name: Deploy
41+
if: github.event_name == 'push'
42+
uses: peaceiris/actions-gh-pages@v3
43+
with:
44+
deploy_key: ${{ secrets.SSH_DEPLOY_KEY }}
45+
publish_dir: ./_site

.github/workflows/docker-nbdev.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build-Nbdev-Docker
2+
on:
3+
schedule:
4+
- cron: '0 */12 * * *'
5+
6+
jobs:
7+
nbdev-docker-fastpages:
8+
if: github.repository == 'fastai/fastpages'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@master
12+
13+
- name: build container
14+
run: |
15+
docker build -t hamelsmu/fastpages-nbdev -f _action_files/fastpages-nbdev.Dockerfile ./_action_files
16+
17+
- name: push container
18+
run: |
19+
echo ${PASSWORD} | docker login -u $USERNAME --password-stdin
20+
docker push hamelsmu/fastpages-nbdev
21+
env:
22+
USERNAME: ${{ secrets.DOCKER_USERNAME }}
23+
PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/docker.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build-Docker
2+
on:
3+
push:
4+
paths:
5+
- Gemfile*
6+
branches:
7+
- master
8+
pull_request:
9+
paths:
10+
- Gemfile*
11+
12+
jobs:
13+
jekyll-fastpages:
14+
if: github.repository == 'fastai/fastpages'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@master
18+
19+
- name: build container
20+
run: |
21+
docker build -t hamelsmu/fastpages-jekyll -f _action_files/fastpages-jekyll.Dockerfile .
22+
23+
- name: push container
24+
if: github.event == 'push'
25+
run: |
26+
echo ${PASSWORD} | docker login -u $USERNAME --password-stdin
27+
docker push hamelsmu/fastpages-jekyll
28+
env:
29+
USERNAME: ${{ secrets.DOCKER_USERNAME }}
30+
PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/gh-page.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: GH-Pages Status
2+
on:
3+
page_build
4+
5+
jobs:
6+
see-page-build-payload:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: check status
10+
run: |
11+
import os
12+
status, errormsg = os.getenv('STATUS'), os.getenv('ERROR')
13+
assert status == 'built', 'There was an error building the page on GitHub pages.\n\nStatus: {}\n\nError messsage: {}'.format(status, errormsg)
14+
shell: python
15+
env:
16+
STATUS: ${{ github.event.build.status }}
17+
ERROR: ${{ github.event.build.error.message }}

0 commit comments

Comments
 (0)