generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c3508fa
Showing
119 changed files
with
5,943 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "fastpages-codespaces", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "watcher", | ||
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], | ||
"forwardPorts": [4000], | ||
"appPort": [4000], | ||
"extensions": ["ms-python.python", | ||
"ms-azuretools.vscode-docker"], | ||
"runServices": ["converter", "jekyll", "watcher"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Set the default behavior, in case people don't have core.autocrlf set. | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Bug | ||
about: Use this template for filing bugs | ||
title: "" | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
## Required Prerequisites for filing a bug | ||
|
||
### 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. | ||
|
||
|
||
## Required information | ||
|
||
1. Steps to reproduce the problem | ||
2. A link to the notebook or markdown file where the error is occurring | ||
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**. | ||
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
name: "[fastpages] Automated Upgrade" | ||
about: "Trigger a PR for upgrading fastpages" | ||
title: "[fastpages] Automated Upgrade" | ||
labels: fastpages-automation | ||
assignees: '' | ||
|
||
--- | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
name: Chatops | ||
on: [issue_comment] | ||
|
||
jobs: | ||
trigger-chatops: | ||
if: (github.event.issue.pull_request != null) && contains(github.event.comment.body, '/preview') && (github.repository == 'fastai/fastpages') | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
CHECK_RUN_NAME: "Draft-Site-Build" | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: see payload | ||
run: | | ||
echo "FULL PAYLOAD:\n${PAYLOAD}\n" | ||
echo "PR_PAYLOAD PAYLOAD:\n${PR_PAYLOAD}" | ||
env: | ||
PAYLOAD: ${{ toJSON(github.event) }} | ||
PR_PAYLOAD: ${{ github.event.pull_request }} | ||
|
||
- name: verify env exists | ||
id: get_status | ||
run: | | ||
if [ -z ${NETLIFY_AUTH_TOKEN} ]; then echo "::set-output name=status::public"; else echo "::set-output name=status::private"; fi | ||
- name: make comment on PR if env does not exist | ||
if: steps.get_status.outputs.status == 'public' | ||
run: | | ||
./_action_files/pr_comment.sh "Was not able to generate site preview due to absent credentials." | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
|
||
- name: Fetch context about the PR that has been commented on | ||
id: chatops | ||
uses: machine-learning-apps/actions-chatops@master | ||
with: | ||
TRIGGER_PHRASE: "/preview" | ||
env: # you must supply GITHUB_TOKEN | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.6 | ||
|
||
- name: install requests | ||
run: pip3 install requests | ||
|
||
- name: add check run | ||
id: create_check | ||
if: steps.get_status.outputs.status == 'private' | ||
shell: python | ||
run: | | ||
import os, requests | ||
sha = os.getenv('SHA') | ||
token = os.getenv('GITHUB_TOKEN') | ||
nwo = os.getenv('GITHUB_REPOSITORY') | ||
name = os.getenv('CHECK_RUN_NAME') | ||
url = f'https://api.github.com/repos/{nwo}/check-runs' | ||
headers = {'authorization': f'token {token}', | ||
'accept': 'application/vnd.github.antiope-preview+json'} | ||
payload = { | ||
'name': f'{name}', | ||
'head_sha': f'{sha}', | ||
'status': 'in_progress', | ||
'output':{ | ||
'title': f'Building preview of site for {sha}.', | ||
'summary': ' ', | ||
'text': ' ' | ||
}, | ||
} | ||
response = requests.post(url=url, headers=headers, json=payload) | ||
print(response) | ||
id = response.json()['id'] | ||
print(f"::set-output name=id::{id}") | ||
env: | ||
SHA: ${{ steps.chatops.outputs.SHA }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: add label | ||
if: steps.get_status.outputs.status == 'private' | ||
run: | | ||
import os, requests | ||
nwo = os.getenv('GITHUB_REPOSITORY') | ||
token = os.getenv('GITHUB_TOKEN') | ||
pr_num = os.getenv('PR_NUM') | ||
headers = {'Accept': 'application/vnd.github.symmetra-preview+json', | ||
'Authorization': f'token {token}'} | ||
url = f"https://api.github.com/repos/{nwo}/issues/{pr_num}/labels" | ||
data = {"labels": ["draft build pending"]} | ||
result = requests.post(url=url, headers=headers, json=data) | ||
# assert response.status_code == 201, f"Received status code of {response.status_code}" | ||
print(result) | ||
shell: python | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUM: ${{ steps.chatops.outputs.PULL_REQUEST_NUMBER }} | ||
GITHUB_REPOSITORY: $GITHUB_REPOSITORY | ||
|
||
- name: Copy The PR's Branch Repository Contents | ||
uses: actions/checkout@master | ||
if: steps.get_status.outputs.status == 'private' | ||
with: | ||
ref: ${{ steps.chatops.outputs.SHA }} | ||
|
||
- name: convert notebooks and word docs to posts | ||
uses: ./ # use the code in this repo to instead of fastai/fastpages@master | ||
|
||
- name: setup directories for Jekyll build | ||
if: steps.get_status.outputs.status == 'private' | ||
run: | | ||
rm -rf _site | ||
sudo chmod -R 777 . | ||
- name: Jekyll build with baseurl as root for netifly | ||
if: steps.get_status.outputs.status == 'private' | ||
uses: docker://hamelsmu/fastpages-jekyll | ||
with: | ||
args: bash -c "gem install bundler && jekyll build" | ||
|
||
- name: deploy to netlify | ||
if: steps.get_status.outputs.status == 'private' | ||
id: py | ||
run: | | ||
sudo npm install netlify-cli -g | ||
netlify deploy --dir _site | tee _netlify_logs.txt | ||
cat _netlify_logs.txt | python _action_files/parse_netlify.py | ||
- name: make comment on PR | ||
if: steps.get_status.outputs.status == 'private' | ||
run: | | ||
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/)" | ||
echo "$MSG" | ||
./_action_files/pr_comment.sh "${MSG}" | ||
env: | ||
URL: ${{ steps.py.outputs.draft_url }} | ||
SHA: ${{ steps.chatops.outputs.SHA }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
|
||
- name: remove label | ||
if: always() | ||
run: | | ||
import os, requests | ||
nwo = os.getenv('GITHUB_REPOSITORY') | ||
token = os.getenv('GITHUB_TOKEN') | ||
pr_num = os.getenv('PR_NUM') | ||
headers = {'Accept': 'application/vnd.github.symmetra-preview+json', | ||
'Authorization': f'token {token}'} | ||
url = f"https://api.github.com/repos/{nwo}/issues/{pr_num}/labels/draft%20build%20pending" | ||
result = requests.delete(url=url, headers=headers) | ||
print(result) | ||
shell: python | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUM: ${{ steps.chatops.outputs.PULL_REQUEST_NUMBER }} | ||
GITHUB_REPOSITORY: $GITHUB_REPOSITORY | ||
|
||
# defensively clear check run each time | ||
- name: clear check run | ||
if: always() | ||
continue-on-error: true | ||
shell: python | ||
run: | | ||
import os, requests | ||
sha = os.getenv('SHA') | ||
conclusion = os.getenv('WORKFLOW_CONCLUSION').lower() | ||
token = os.getenv('GITHUB_TOKEN') | ||
nwo = os.getenv('GITHUB_REPOSITORY') | ||
check_run_id = os.getenv('CHECK_RUN_ID') | ||
if not check_run_id: | ||
quit() | ||
url = f'https://api.github.com/repos/{nwo}/check-runs/{check_run_id}' | ||
headers = {'authorization': f'token {token}', | ||
'accept': 'application/vnd.github.antiope-preview+json'} | ||
data = { | ||
'conclusion': f'{conclusion}', | ||
} | ||
response = requests.patch(url=url, headers=headers, json=data) | ||
print(response) | ||
env: | ||
SHA: ${{ steps.chatops.outputs.SHA }} | ||
WORKFLOW_CONCLUSION: ${{ job.status }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CHECK_RUN_ID: ${{ steps.create_check.outputs.id }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Check Configurations | ||
on: push | ||
|
||
jobs: | ||
check-config: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- 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.' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master # need to filter here so we only deploy when there is a push to master | ||
# no filters on pull requests, so intentionally left blank | ||
pull_request: | ||
|
||
jobs: | ||
build-site: | ||
if: ( github.event.commits[0].message != 'Initial commit' ) || github.run_number > 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Copy Repository Contents | ||
uses: actions/checkout@master | ||
with: | ||
persist-credentials: false | ||
|
||
- name: convert notebooks and word docs to posts | ||
uses: ./_action_files | ||
|
||
- name: setup directories for Jekyll build | ||
run: | | ||
rm -rf _site | ||
sudo chmod -R 777 . | ||
- name: Jekyll build | ||
uses: docker://hamelsmu/fastpages-jekyll | ||
with: | ||
args: bash -c "gem install bundler && jekyll build -V --strict_front_matter --trace" | ||
env: | ||
JEKYLL_ENV: 'production' | ||
|
||
- name: copy CNAME file into _site if CNAME exists | ||
run: | | ||
sudo chmod -R 777 _site/ | ||
cp CNAME _site/ 2>/dev/null || : | ||
- name: Deploy | ||
if: github.event_name == 'push' | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
deploy_key: ${{ secrets.SSH_DEPLOY_KEY }} | ||
publish_dir: ./_site |
Oops, something went wrong.