Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shreya-ahujaa committed Aug 19, 2022
0 parents commit a83c1d7
Show file tree
Hide file tree
Showing 139 changed files with 8,012 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .devcontainer.json
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, 8080],
"appPort": [4000, 8080],
"extensions": ["ms-python.python",
"ms-azuretools.vscode-docker"],
"runServices": ["converter", "notebook", "jekyll", "watcher"]
}

2 changes: 2 additions & 0 deletions .gitattributes
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
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
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).
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
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.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/upgrade.md
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 latest version of [fastpages](https://github.com/fastai/fastpages). More information will be provided in forthcoming comments below.
198 changes: 198 additions & 0 deletions .github/workflows/chatops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: Chatops
on: [issue_comment]

permissions:
actions: write
pull-requests: write
contents: write

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@main
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://fastai/fastpages-jekyll
with:
args: bash -c "jekyll build"

- name: deploy to netlify
if: steps.get_status.outputs.status == 'private'
id: py
run: |
sudo npm install -g --unsafe-perm=true netlify-cli
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 }}
13 changes: 13 additions & 0 deletions .github/workflows/check_cdns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Check CDN
on:
# push:
# schedule:
# - cron: '1 7,14,21 * * *'
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- run: ./_action_files/check_js.sh
83 changes: 83 additions & 0 deletions .github/workflows/check_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Check Configurations
on: push

permissions:
actions: write
pull-requests: write
contents: write

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/github-script@0.6.0
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/github-script@0.6.0
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.'
})
Loading

0 comments on commit a83c1d7

Please sign in to comment.