generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from akagr/fastpages-automated-upgrade
[fastpages] Update repo with changes from fastpages
- Loading branch information
Showing
10 changed files
with
160 additions
and
11 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
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,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 | ||
}) |
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,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}` | ||
}) |
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
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
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
2.1.44 | ||
2.1.47 |
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
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