Skip to content

Commit

Permalink
Merge pull request #3 from akagr/fastpages-automated-upgrade
Browse files Browse the repository at this point in the history
[fastpages] Update repo with changes from fastpages
  • Loading branch information
akagr authored May 24, 2021
2 parents 82f391c + 4955e9f commit d2bc7a9
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ 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.
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.
26 changes: 26 additions & 0 deletions .github/workflows/issue_reminder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

name: Issue Reminder
on:
issues:
types: [opened]

jobs:
issue_comment:
if: |
(github.repository == 'fastai/fastpages')
runs-on: ubuntu-latest
steps:

- name: Comment on issue
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var url = 'https://github.com/fastai/fastpages/blob/master/_fastpages_docs/TROUBLESHOOTING.md'
var msg = `Thank you for opening an issue. If this issue is related to a bug, please follow the steps and provide the information outlined in the [Troubleshooting Guide](${url}). Failure to follow these instructions may result in automatic closing of this issue.`
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: msg
})
105 changes: 105 additions & 0 deletions .github/workflows/setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Setup
on: push

jobs:
setup:
if: (github.event.commits[0].message == 'Initial commit') && (github.run_number == 1)
runs-on: ubuntu-latest
steps:

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6

- name: Copy Repository Contents
uses: actions/checkout@v2

- name: modify files
run: |
import re, os
from pathlib import Path
from configparser import ConfigParser
config = ConfigParser()
nwo = os.getenv('GITHUB_REPOSITORY')
username, repo_name = nwo.split('/')
readme_template_path = Path('_fastpages_docs/README_TEMPLATE.md')
readme_path = Path('README.md')
config_path = Path('_config.yml')
pr_msg_path = Path('_fastpages_docs/_setup_pr_template.md')
settings = Path('_action_files/settings.ini')
assert readme_template_path.exists(), 'Did not find _fastpages_docs/README_TEMPLATE.md in the current directory!'
assert readme_path.exists(), 'Did not find README.md in the current directory!'
assert config_path.exists(), 'Did not find _config.yml in the current directory!'
assert pr_msg_path.exists(), 'Did not find _fastpages_docs/_setup_pr_template.md in the current directory!'
assert settings.exists(), 'Did not find _action_files/settings.ini in the current directory!'
# edit settings.ini file to inject baseurl
config.read(settings)
config['DEFAULT']['baseurl'] = f'/{repo_name}'
with open('_action_files/settings.ini', 'w') as configfile:
config.write(configfile)
# replace content of README with template
readme = readme_template_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
readme_path.write_text(readme)
# update _config.yml
cfg = config_path.read_text()
cfg = re.sub(r'^(github_username: )(fastai)', fr'\g<1>{username}', cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(baseurl: )("")', r'\1"/{}"'.format(repo_name), cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(github_repo: ")(fastpages)', r'\1{}'.format(repo_name), cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(url: "https://)(fastpages.fast.ai)(")', fr'\g<1>{username}.github.io\3', cfg, flags=re.MULTILINE)
cfg = re.sub('UA-57531313-5', '', cfg, flags=re.MULTILINE)
config_path.write_text(cfg)
# prepare the pr message
pr = pr_msg_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
pr_msg_path.write_text(pr)
shell: python

- name: commit changes
run: |
git config --global user.email "${GH_EMAIL}"
git config --global user.name "${GH_USERNAME}"
git checkout -B fastpages-automated-setup
git rm CNAME action.yml
git rm _notebooks/2020-02-21-introducing-fastpages.ipynb
git rm _notebooks/2020-09-01-fastcore.ipynb || true
git rm _notebooks/2020-11-17-linkcheck.ipynb || true
git rm -rf _notebooks/fastcore_imgs
git rm -rf _notebooks/fastlinkcheck_images
git rm _posts/2020-03-06-fastpages-actions.md
git rm _posts/*codespaces.md || true
git rm -rf images/fastpages_posts
git rm .github/workflows/chatops.yaml
git rm .github/workflows/docker.yaml
git rm .github/workflows/issue_reminder.yaml
git rm .github/workflows/setup.yaml
git rm .github/ISSUE_TEMPLATE/bug.md
git rm .github/ISSUE_TEMPLATE/feature_request.md
git rm _word/*.docx
git add _config.yml README.md _fastpages_docs/ _action_files/settings.ini
git commit -m'setup repo'
git push -f --set-upstream origin fastpages-automated-setup
env:
GH_EMAIL: ${{ github.event.commits[0].author.email }}
GH_USERNAME: ${{ github.event.commits[0].author.username }}

- name: Open a PR
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var fs = require('fs');
var contents = fs.readFileSync('_fastpages_docs/_setup_pr_template.md', 'utf8');
github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Initial Setup',
head: 'fastpages-automated-setup',
base: 'master',
body: `${contents}`
})
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ GEM
jekyll (>= 3.0, < 5.0)
katex (0.6.0)
execjs (~> 2.7)
kramdown (2.3.0)
kramdown (2.3.1)
rexml
kramdown-math-katex (1.0.1)
katex (~> 0.4)
Expand Down
6 changes: 6 additions & 0 deletions _fastpages_docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ See the [Upgrading guide](https://github.com/fastai/fastpages/blob/master/_fastp

2. Can you customize the styling or theme of fastpages? **A**: See [Customizing Fastpages](https://github.com/fastai/fastpages#customizing-fastpages)

3. Your initial build failed on GH-Pages Status

`Error messsage: Unable to build page. Please try again later.` `Error: Process completed with exit code 1.`

If your github username contains capital letters e.g. YourUserName, go to [config file](../_config.yml#L17) line 17 and rename `YourUserName.github.io` to `yourusername.github.io`. After the commit blog should build without error.

See the [FAQ](https://github.com/fastai/fastpages#faq) for frequently asked questions.
5 changes: 4 additions & 1 deletion _fastpages_docs/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- [Additional Resources](#additional-resources)
<!-- /TOC -->


**For fastpages repos that are older than December 1st, 2020 the only way to upgrade is to create a brand-new fastpages repo and copy your blog post files into it.** This is because of breaking changes that were made to GitHub Actions around that time.

There are two ways to upgrade fastpages. One is an automated way that assumes you have made no changes to the HTML of your site. Alternatively, you may [upgrade manually](#manual-upgrade) and determine which changes to accept or reject. For most people we recommend upgrading fastpages automatically.

## Automated Upgrade
Expand Down Expand Up @@ -42,7 +45,7 @@ There are two ways to upgrade fastpages. One is an automated way that assumes y
It is possible that you might receive an error message instead of this command. You can follow the instructions in the comment to troubleshoot the issue. Common reasons for receiving an error are:

- You are up to date, therefore no upgrade is possible. You will see an error that there is "nothing to commit".
- You already have a PR from a prevoius upgrade open that you never merged.
- You already have a PR from a previous upgrade open that you never merged.

Please [ask on the forums](https://forums.fast.ai/) if you have encounter another problem that is unclear.

Expand Down
6 changes: 3 additions & 3 deletions _fastpages_docs/_upgrade_pr.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hello :wave: @{_username_}!
Hello :wave: @akagr!

This PR pulls the most recent files from [fastpages](https://github.com/fastai/fastpages), and attempts to replace relevant files in your repository, without changing the content of your blog posts. This allows you to receive bug fixes and feature updates.

Expand All @@ -10,5 +10,5 @@ If you would like more fine-grained control over what changes to accept or decli

### What to Expect After Merging This PR

- GitHub Actions will build your site, which will take 3-4 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/{_username_}/{_repo_name_}/actions).
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/{_username_}/{_repo_name_}/settings).
- GitHub Actions will build your site, which will take 3-4 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/akagr/blog/actions).
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/akagr/blog/settings).
2 changes: 1 addition & 1 deletion _fastpages_docs/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.44
2.1.47
11 changes: 10 additions & 1 deletion _includes/google-analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@

{% if site.google_analytics %}

<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','{{site.google_analytics}}','auto');ga('require','displayfeatures');ga('send','pageview');</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{site.google_analytics}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{site.google_analytics}}');
</script>

{% endif %}
6 changes: 3 additions & 3 deletions _sass/minima/fastpages-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ table {
// Handling large charts on mobile devices
// @media only screen and (max-width: 1200px) {
// /* for mobile phone and tablet devices */
// .output_wrapper{
// overflow: scroll;
// }
.output_wrapper{
overflow: auto;
}
// }

.svg-icon.orange{
Expand Down

0 comments on commit d2bc7a9

Please sign in to comment.