diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md deleted file mode 100644 index 6c6b97e..0000000 --- a/.github/ISSUE_TEMPLATE/bug.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Bug -about: Use this template for filing bugs -title: "[DATE]: [FEATURE NAME]" -labels: bug -assignees: '' - ---- - -## Required Prerequisites for filing a bug - -#### You must check both boxes - -- [ ] Have you searched opened / closed issues on this repo for a similar problem? -- [ ] Have you searched the [fastai forums](https://forums.fast.ai/) for a similar problem? - - -## Required information - -#### Failure to provide this information or going through these steps will result in automatic closing of the issue - -1. Steps to reproduce the problem -2. A link to the notebook or markdown file where the error is occuring -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. 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)? diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 11fc491..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -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. diff --git a/.github/workflows/chatops.yaml b/.github/workflows/chatops.yaml deleted file mode 100644 index 89b45b8..0000000 --- a/.github/workflows/chatops.yaml +++ /dev/null @@ -1,195 +0,0 @@ -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 }} - diff --git a/.github/workflows/docker-nbdev.yaml b/.github/workflows/docker-nbdev.yaml deleted file mode 100644 index 49c7224..0000000 --- a/.github/workflows/docker-nbdev.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Build-Nbdev-Docker -on: - schedule: - - cron: '0 */12 * * *' - -jobs: - nbdev-docker-fastpages: - if: github.repository == 'fastai/fastpages' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - - name: build container - run: | - docker build -t hamelsmu/fastpages-nbdev -f _action_files/fastpages-nbdev.Dockerfile ./_action_files - - - name: push container - run: | - echo ${PASSWORD} | docker login -u $USERNAME --password-stdin - docker push hamelsmu/fastpages-nbdev - env: - USERNAME: ${{ secrets.DOCKER_USERNAME }} - PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 3478633..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build-Docker -on: - push: - paths: - - Gemfile* - branches: - - master - pull_request: - paths: - - Gemfile* - -jobs: - jekyll-fastpages: - if: github.repository == 'fastai/fastpages' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - - name: setup directories for Jekyll build - run: sudo chmod -R 777 . - - - name: build container - run: | - docker build -t hamelsmu/fastpages-jekyll -f _action_files/fastpages-jekyll.Dockerfile . - - - name: push container - if: github.event == 'push' - run: | - echo ${PASSWORD} | docker login -u $USERNAME --password-stdin - docker push hamelsmu/fastpages-jekyll - env: - USERNAME: ${{ secrets.DOCKER_USERNAME }} - PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/CNAME b/CNAME deleted file mode 100644 index 8b13789..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ - diff --git a/README.md b/README.md index 79ce2a7..dbee07c 100644 --- a/README.md +++ b/README.md @@ -1,152 +1,29 @@ -[//]: # (BADGES SECTION: change `fastai` with your GitHub username and `fastpages` with the name of your repo) +[//]: # (This template replaces README.md when someone creates a new repo with the fastpages template.) -![](https://github.com/EasonQYS/fastpagesJupyter/workflows/CI/badge.svg) -![](https://github.com/EasonQYS/fastpagesJupyter/workflows/GH-Pages%20Status/badge.svg) -[![](https://img.shields.io/static/v1?label=fastai&message=nbdev&color=57aeac&labelColor=black&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAjCAYAAABhCKGoAAAGMklEQVR42q1Xa0xTVxyfKExl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View%20Demo%20Site&message=link&labelColor=2f363d&color=blue&style=flat&logo=github&logoColor=959da5)](https://easonqys.github.io/fastpagesJupyter/) +![](https://github.com/Cyber-I/cyberlog/workflows/CI/badge.svg) +![](https://github.com/Cyber-I/cyberlog/workflows/GH-Pages%20Status/badge.svg) +[![](https://img.shields.io/static/v1?label=fastai&message=fastpages&color=57aeac&labelColor=black&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAjCAYAAABhCKGoAAAGMklEQVR42q1Xa0xTVxyfKExlui9blszoB12yDzPGzJhtyT5s+zBxUxELBQSHm2ZzU5epBF/LclXae29pCxR5VEGgLQUuIOKDuClhm8oUK7S9ve19tLTl/fA5p9MNc/Y/hRYEzGLxJL/87zk9Ob/zf5++NGHMALzYgdDYmWh0Qly3Lybtwi6lXdpN2cWN5A0+hrQKe5R2PoN2uD+OKcn/UF5ZsVduMmyXVRi+jzebdmI5/juhwrgj3mTI2GA0vvsUIcMwM7GkOD42t7Mf6bqHkFry2yk7X5PXcxMVDN5DGtFf9NkJfe6W5iaUyFShjfV1KPlk7VPAa0k11WjzL+eRvMJ4IKQO0dw8SydJL+Op0u5cn+3tQTn+fqTivTbQpiavF0iG7iGt6NevKjpKpTbUo3hj+QO47XB8hfHfIGAelA+T6mqQzFi+e0oTKm3iexQnXaU56ZrK5SlVsq70LMF7TuX0XNTyvi1rThzLST3TgOCgxwD0DPwDGoE07QkcSl/m5ynbHWmZVm6b0sp9o2DZN8aTZtqk9w9b2G2HLbbvsjlx+fry0vwU0OS5SH68Ylmilny3c3x9SOvpRuQN7hO8vqulZQ6WJMuXFAzcRfkDd5BG8B1bpc+nU0+fQtgkYLIngOEJwGt/J9UxCIJg1whJ05Ul4IMejbsLqUUfOjJKQnCDr4ySHMeO1/UMIa3UmR9TUpj7ZdMFJK8yo6RaZjLAF/JqM/rifCO+yP4AycGmlgUaT9cZ0OYP2um5prjBLhtvLhy68Fs7RFqbRvSlf15ybGdyLcPJmcpfIcIu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TrfuAhAWacPslUiQRNLBGXFSA7TrL8V3gNhesTnLFY0jb+bYWVp0i7SClY184jVtcayi7so2yuA0r4npbjsV8CJHZhPQ7no323cJ5w8FqpLwR/YJNRnHs0hNGs6ZFw/Lpsb+9oj/dZSbuL0XUNojx4d9Gch5mOT0ImINsdKyHzT9Muz1lcXhRWbo9a8J3B72H8Lg6+bKb1hyWMPeERBXMGRxEBCM7Ddfh/1jDuWhb5+QkAAAAASUVORK5CYII=)](https://github.com/fastai/fastpages) -[//]: # (END OF BADGES SECTION) +https://Cyber-I.github.io/cyberlog/ -# 欢迎使用 `fastpages` +# My Blog -> 一款简单的博客网站,支持 Jupyter 笔记本, Word 文档, 以及 Markdown. ->原作链接在此:[fastai/fastpages](https://github.com/fastai/fastpages/),是英文的。 +_powered by [fastpages](https://github.com/fastai/fastpages)_ -![](images/diagram.png) -`fastpages` 用 [GitHub Actions](https://github.com/features/actions)来简化多种格式文档(Jupyter 笔记本, Word 文档, 以及 Markdown)在[GitHub Pages](https://pages.github.com/)上转换为HTML格式的[Jekyll博客帖](https://jekyllrb.com/)的过程。 +## What To Do Next? -### `fastpages` 提供以下功能: +Great! You have setup your repo. Now its time to start writing content. Some helpful links: -- 建立博客帖。可以包含代码,运行结果,带格式文本等等。 使用[Jupyter Notebooks](https://jupyter.org/)可以轻松实现; 博客支持以下特性: - - 使用[Altair](https://altair-viz.github.io/)保持Jupyter的可交互性。 - - 显示或隐藏单元格。 - - 通过特殊的Markdown表格定义标题,概要,以及其他内容。 - - 提供链接到[Colab](https://colab.research.google.com/) 以及GitHub。 -- 通过GitHub Issues来发表评论。 -- 快速查找历史博客。 -- 修改网站风格。 -- 嵌入推特或油管视频。 -- 通过标签分类。 -- 建立[Markdown](https://guides.github.com/features/mastering-markdown/)格式的博客。 -- 支持带格式和图片的word文档的博客页面。 -- 本地写好并实时预览。 +- [Writing Blogs With Jupyter](https://github.com/fastai/fastpages#writing-blog-posts-with-jupyter) -看下去了解更多细节。 +- [Writing Blogs With Markdown](https://github.com/fastai/fastpages#writing-blog-posts-with-markdown) +- [Writing Blog Posts With Word](https://github.com/fastai/fastpages#writing-blog-posts-with-microsoft-word) -**[看看模板网站](https://easonqys.github.io/fastpagesJupyter/)** - ---- - - - -- [欢迎使用 `fastpages`](#欢迎使用-fastpages) - - [初始化指导](#初始化指导) - - [编写博客](#编写博客) - - [编写表头](#编写表头) - - [编写其他内容](#编写其他内容) -- [查看英文原生文档](#查看英文原生文档) -- [问答](#faq) - - - - -## 初始化指导 - -1. 点击 [这个链接](https://github.com/EasonQYS/fastpagesJupyter/generate) 生成一个自己的仓库(repository,repo),用于运行博客。 随意给仓库起名字,但是 **请勿使用** {your-username}.github.io. - -2. **GitHub Actions 会自动拉取请求(Pull Request,PR)** ~ ,大约30s完成。 完成后会在你的仓库有一个README.md文档,根据那里的指导继续操作。 - -想要看视频指导,可以访问这个YouTube网址,但是国内看不了。 [video tutorial of setting up a fastpages blog](https://youtu.be/L0boq3zqazI) by Abdul Majed. 当然,根据文字指导也没有问题。 - -3. 你或许会收到一封指导邮件,但由于邮件是英文的,你可以忽视邮件,按以下指导操作。 - - - 3.1 生成SSH密钥对。访问[这里](https://8gwifi.org/sshfunctions.jsp),选择RSA和4096,点击生成(Generate-SSH-Keys),就会可到两串字符。 - - - 3.2 设置仓库(repo)的Secrets。在当前仓库地址后加/settings/secrets,或者访问settings>secrets,点击添加new secret。复制3.1中的Private Key至Value栏,包含"---BEGIN RSA PRIVATE KEY---" 和 "--END RSA PRIVATE KEY---"。在Name栏填写SSH_DEPLOY_KEY(只能是这个名字)。 - - - 3.3 设置仓库(repo)的deploy key。在当前仓库地址后加/settings/keys,或者访问settings>Deploy keys,点击添加deploy key。复制3.1中的Public Key至key栏,name栏随意填写。请注意勾选`Allow write access`。点击Add key保存设置。 - - - 3.4 启用网站。点击[这里](/settings)找到GitHub Pages,source选择gh-pages branch(如果没有可以先选择其他项,稍后自动生成gh-pages branch后可以再修改)。等待一段时间,GitHub Pages栏生成一个网址,点击即可访问该网站。 - -4. 修改_config.yml。需要修改的部分已经在文档内用中文标注。 - -5. 完成后等待约10分钟,网站自动建立成功。如果之前branch选择不是gh-pages,现在需要更改为gh-pages。 - - - -## 编写博客 - -### 编写表头 - -[表头](https://jekyllrb.com/docs/front-matter/) 允许你设置博客的很多属性。 - -在Jupyter中,表头是文档中的第一个单元格。并且是markdown格式的单元格。内容如下(可以缺省): - - ```markdown - # "标题" - > "概要" - - - toc: true - - badges: true - - comments: true - - categories: [fastpages, jupyter] - - image: images/some_folder/your_image.png - - author: A & B - ``` - -类似的, 在一个markdown文档中,也需要表头。内容如下: - - ```yaml - --- - title: "标题" - summary: "概要" - toc: true - comments: true - image: images/some_folder/your_image.png - categories: [fastpages, jupyter] - --- - ``` -注意这里的代码是以YAML格式写的,必须保证正确。 - -更多[YAML指导](https://rollout.io/blog/yaml-tutorial-everything-you-need-get-started/)请看这里。 - -### 编写其他内容 - 正常编写即可。 - - 需要说明的是Jupyter和Markdown**插入图片**的时候需要先上传图片,再引用到文档。例如我将图片传至根目录下的images文件夹,那么在Jupyter和Markdown中写以下代码即可引用。 - ``` - ![描述](images/filename.jpg "图片标题") - ``` - -# 查看英文原生文档 -更多内容查阅原生文档:[fastai/fastpages](https://github.com/fastai/fastpages/)。 - -# FAQ -# 问答(英文) -- **Q:** Where are the markdown files in `_posts/` that are generated from my Jupyter notebooks or word documents? - -- **A:** The GitHub Actions workflow in this repo converts your notebook and word documents to markdown on the fly before building your site, but never commits these intermediate markdown files to this repo. This is in order to save you from the annoyance of your local environment being constantly out of sync with your repository. You can optionally see these intermediate markdown files by setting the `BOOL_SAVE_MARKDOWN` and `SSH_DEPLOY_KEY` inputs to the fastpages action in your `.github/workflows/ci.yaml` file as follows: - -```yaml - ... - - - name: convert notebooks and word docs to posts - uses: fastai/fastpages@master - with: - BOOL_SAVE_MARKDOWN: true - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - - ... -``` - -- **Q:** Can I use `fastpages` for Jekyll docs sites or for things that are not Jekyll blog posts? - -- **A:** At the moment, `fastpages` is a highly opinionated solution that works only for Jekyll blog posts. If you want to write documentation for your module or library with Jupyter notebooks, we suggest you use [fastai/nbdev](https://github.com/fastai/nbdev) which is expressly built for this purpose. - -- **Q:** What is the difference between [fast_template](https://github.com/fastai/fast_template) and fastpages? Which one should I use? -- **A:** Because `fastpages` is more flexible and extensible, we recommend using it where possible. `fast_template` may be a better option for getting folks blogging who have no technical expertise at all, and will only be creating posts using Github's integrated online editor. +- [(Optional) Preview Your Blog Locally](_fastpages_docs/DEVELOPMENT.md) +Note: you may want to remove example blog posts from the `_posts`, `_notebooks` or `_word` folders (but leave them empty, don't delete these folders) if you don't want these blog posts to appear on your site. +Please use the [nbdev & blogging channel](https://forums.fast.ai/c/fastai-users/nbdev/48) in the fastai forums for any questions or feature requests. diff --git a/_action_files/settings.ini b/_action_files/settings.ini index 415570d..3ea2c51 100644 --- a/_action_files/settings.ini +++ b/_action_files/settings.ini @@ -7,7 +7,7 @@ description = Writing a library entirely in notebooks keywords = jupyter notebook author = Sylvain Gugger and Jeremy Howard author_email = info@fast.ai -baseurl = +baseurl = /cyberlog title = nbdev copyright = fast.ai license = apache2 @@ -41,3 +41,4 @@ custom_sidebar = False cell_spacing = 1 monospace_docstrings = False jekyll_styles = note,warning,tip,important,youtube,twitter + diff --git a/_config.yml b/_config.yml index eb35660..b57e05a 100644 --- a/_config.yml +++ b/_config.yml @@ -10,7 +10,7 @@ title: 中文博客模板 description: 便捷实用的Jupyter博客网站。此外,还支持 Word 文档,以及 Markdown。 github_username: EasonQYS # 你的用户名 # you can comment the below line out if your repo name is not different than your baseurl -github_repo: "fastpagesJupyter" #你的仓库名 +github_repo: "cyberlogJupyter" #你的仓库名 # OPTIONAL: override baseurl and url if using a custom domain 可选项,如果你有自己的域名,并且需要绑定到该网站 # Note: leave out the trailing / from this value. 写下域名,不要在最后加斜杠/ diff --git a/_fastpages_docs/_setup_pr_template.md b/_fastpages_docs/_setup_pr_template.md index ee71d2e..898bf50 100644 --- a/_fastpages_docs/_setup_pr_template.md +++ b/_fastpages_docs/_setup_pr_template.md @@ -1,25 +1,25 @@ -Hello :wave: @{_username_}! Thank you for using fastpages! +Hello :wave: @Cyber-I! Thank you for using fastpages! ## Before you merge this PR 1. Create an ssh key-pair. Open this utility. Select: `RSA` and `4096` and leave `Passphrase` blank. Click the blue button `Generate-SSH-Keys`. -2. Navigate to this link and click `Add a new secret`. Copy and paste the **Private Key** into the `Value` field. This includes the "---BEGIN RSA PRIVATE KEY---" and "--END RSA PRIVATE KEY---" portions. In the `Name` field, name the secret `SSH_DEPLOY_KEY`. +2. Navigate to this link and click `Add a new secret`. Copy and paste the **Private Key** into the `Value` field. This includes the "---BEGIN RSA PRIVATE KEY---" and "--END RSA PRIVATE KEY---" portions. In the `Name` field, name the secret `SSH_DEPLOY_KEY`. -3. Navigate to this link and click the `Add deploy key` button. Paste your **Public Key** from step 1 into the `Key` box. In the `Title`, name the key anything you want, for example `fastpages-key`. Finally, **make sure you click the checkbox next to `Allow write access`** (pictured below), and click `Add key` to save the key. +3. Navigate to this link and click the `Add deploy key` button. Paste your **Public Key** from step 1 into the `Key` box. In the `Title`, name the key anything you want, for example `fastpages-key`. Finally, **make sure you click the checkbox next to `Allow write access`** (pictured below), and click `Add key` to save the key. ![](https://raw.githubusercontent.com/fastai/fastpages/master/_fastpages_docs/_checkbox.png) ### What to Expect After Merging This PR -- GitHub Actions will build your site, which will take 2-3 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). +- GitHub Actions will build your site, which will take 2-3 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/Cyber-I/cyberlog/actions). - Your GH-Pages Status badge on your README will eventually appear and be green, indicating your first sucessfull build. -- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/{_username_}/{_repo_name_}/settings). +- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/Cyber-I/cyberlog/settings). If you are not using a custom domain, your website will appear at: -#### https://{_username_}.github.io/{_repo_name_} +#### https://Cyber-I.github.io/cyberlog ## Optional: Using a Custom Domain diff --git a/_notebooks/2020-02-21-introducing-fastpages.ipynb b/_notebooks/2020-02-21-introducing-fastpages.ipynb deleted file mode 100644 index 882fe25..0000000 --- a/_notebooks/2020-02-21-introducing-fastpages.ipynb +++ /dev/null @@ -1,549 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Introducing fastpages\n", - "> An easy to use blogging platform with extra features for Jupyter Notebooks.\n", - "\n", - "- toc: true \n", - "- badges: true\n", - "- comments: true\n", - "- author: Jeremy Howard & Hamel Husain\n", - "- image: images/diagram.png\n", - "- categories: [fastpages, jupyter]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![](https://github.com/fastai/fastpages/raw/master/images/diagram.png \"https://github.com/fastai/fastpages\")\n", - "\n", - "We are very pleased to announce the immediate availability of [fastpages](https://github.com/fastai/fastpages). `fastpages` is a platform which allows you to create and host a blog for free, with no ads and many useful features, such as:\n", - "\n", - "- Create posts containing code, outputs of code (which can be interactive), formatted text, etc directly from [Jupyter Notebooks](https://jupyter.org/); for instance see this great [example post](https://drscotthawley.github.io/devblog3/2019/02/08/My-1st-NN-Part-3-Multi-Layer-and-Backprop.html) from Scott Hawley. Notebook posts support features such as:\n", - " - Interactive visualizations made with [Altair](https://altair-viz.github.io/) remain interactive.\n", - " - Hide or show cell input and output.\n", - " - Collapsable code cells that are either open or closed by default.\n", - " - Define the Title, Summary and other metadata via a special markdown cells\n", - " - Ability to add links to [Colab](https://colab.research.google.com/) and GitHub automatically.\n", - "- Create posts, including formatting and images, directly from Microsoft Word documents.\n", - "- Create and edit [Markdown](https://guides.github.com/features/mastering-markdown/) posts entirely online using GitHub's built-in markdown editor.\n", - "- Embed Twitter cards and YouTube videos.\n", - "- Categorization of blog posts by user-supplied tags for discoverability.\n", - "- ... and [much more](https://github.com/fastai/fastpages)\n", - "\n", - "[fastpages](https://github.com/fastai/fastpages) relies on Github pages for hosting, and [Github Actions](https://github.com/features/actions) to automate the creation of your blog. The setup takes around three minutes, and does not require any technical knowledge or expertise. Due to built-in automation of fastpages, you don't have to fuss with conversion scripts. All you have to do is save your Jupyter notebook, Word document or markdown file into a specified directory and the rest happens automatically. Infact, this blog post is written in a Jupyter notebook, which you can see with the \"View on GitHub\" link above.\n", - "\n", - "[fast.ai](https://www.fast.ai/) have previously released a similar project called [fast_template](https://www.fast.ai/2020/01/16/fast_template/), which is even easier to set up, but does not support automatic creation of posts from Microsoft Word or Jupyter notebooks, including many of the features outlined above.\n", - "\n", - "**Because `fastpages` is more flexible and extensible, we recommend using it where possible.** `fast_template` may be a better option for getting folks blogging who have no technical expertise at all, and will only be creating posts using Github's integrated online editor." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setting Up Fastpages\n", - "\n", - "[The setup process](https://github.com/fastai/fastpages#setup-instructions) of fastpages is automated with GitHub Actions, too! Upon creating a repo from the fastpages template, a pull request will automatically be opened (after ~ 30 seconds) configuring your blog so it can start working. The automated pull request will greet you with instructions like this:\n", - "\n", - "![Imgur](https://i.imgur.com/JhkIip8.png)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "All you have to do is follow these instructions (in the PR you receive) and your new blogging site will be up and running!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Jupyter Notebooks & Fastpages\n", - "\n", - "In this post, we will cover special features that fastpages provides has for Jupyter notebooks. You can also write your blog posts with Word documents or markdown in fastpages, which contain many, but not all the same features. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Options via FrontMatter\n", - "\n", - "The first cell in your Jupyter Notebook or markdown blog post contains front matter. Front matter is metadata that can turn on/off options in your Notebook. It is formatted like this:\n", - "\n", - "```\n", - "# Title\n", - "> Awesome summary\n", - "\n", - "- toc: true\n", - "- branch: master\n", - "- badges: true\n", - "- comments: true\n", - "- author: Hamel Husain & Jeremy Howard\n", - "- categories: [fastpages, jupyter]\n", - "```\n", - "\n", - "**All of the above settings are enabled in this post, so you can see what they look like!**\n", - "\n", - "- the summary field (preceeded by `>`) will be displayed under your title, and will also be used by social media to display as the description of your page.\n", - "- `toc`: setting this to `true` will automatically generate a table of contents\n", - "- `badges`: setting this to `true` will display Google Colab and GitHub links on your blog post.\n", - "- `comments`: setting this to `true` will enable comments. See [these instructions](https://github.com/fastai/fastpages#enabling-comments) for more details.\n", - "- `author` this will display the authors names. \n", - "- `categories` will allow your post to be categorized on a \"Tags\" page, where readers can browse your post by categories.\n", - "\n", - "\n", - "_Markdown front matter is formatted similarly to notebooks. The differences between the two can be [viewed on the fastpages README](https://github.com/fastai/fastpages#front-matter-related-options)._" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Code Folding" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "put a `#collapse-hide` flag at the top of any cell if you want to **hide** that cell by default, but give the reader the option to show it:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "#collapse-hide\n", - "import pandas as pd\n", - "import altair as alt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "put a `#collapse-show` flag at the top of any cell if you want to **show** that cell by default, but give the reader the option to hide it:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "#collapse-show\n", - "cars = 'https://vega.github.io/vega-datasets/data/cars.json'\n", - "movies = 'https://vega.github.io/vega-datasets/data/movies.json'\n", - "sp500 = 'https://vega.github.io/vega-datasets/data/sp500.csv'\n", - "stocks = 'https://vega.github.io/vega-datasets/data/stocks.csv'\n", - "flights = 'https://vega.github.io/vega-datasets/data/flights-5k.json'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you want to completely hide cells (not just collapse them), [read these instructions](https://github.com/fastai/fastpages#hide-inputoutput-cells)." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "# hide\n", - "df = pd.read_json(movies) # load movies data\n", - "genres = df['Major_Genre'].unique() # get unique field values\n", - "genres = list(filter(lambda d: d is not None, genres)) # filter out None values\n", - "genres.sort() # sort alphabetically" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Interactive Charts With Altair\n", - "\n", - "Interactive visualizations made with [Altair](https://altair-viz.github.io/) remain interactive! \n", - "\n", - "We leave this below cell unhidden so you can enjoy a preview of syntax highlighting in fastpages, which uses the [Dracula theme](https://draculatheme.com/)." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
\n", - "" - ], - "text/plain": [ - "alt.LayerChart(...)" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# select a point for which to provide details-on-demand\n", - "label = alt.selection_single(\n", - " encodings=['x'], # limit selection to x-axis value\n", - " on='mouseover', # select on mouseover events\n", - " nearest=True, # select data point nearest the cursor\n", - " empty='none' # empty selection includes no data points\n", - ")\n", - "\n", - "# define our base line chart of stock prices\n", - "base = alt.Chart().mark_line().encode(\n", - " alt.X('date:T'),\n", - " alt.Y('price:Q', scale=alt.Scale(type='log')),\n", - " alt.Color('symbol:N')\n", - ")\n", - "\n", - "alt.layer(\n", - " base, # base line chart\n", - " \n", - " # add a rule mark to serve as a guide line\n", - " alt.Chart().mark_rule(color='#aaa').encode(\n", - " x='date:T'\n", - " ).transform_filter(label),\n", - " \n", - " # add circle marks for selected time points, hide unselected points\n", - " base.mark_circle().encode(\n", - " opacity=alt.condition(label, alt.value(1), alt.value(0))\n", - " ).add_selection(label),\n", - "\n", - " # add white stroked text to provide a legible background for labels\n", - " base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(\n", - " text='price:Q'\n", - " ).transform_filter(label),\n", - "\n", - " # add text labels for stock prices\n", - " base.mark_text(align='left', dx=5, dy=-5).encode(\n", - " text='price:Q'\n", - " ).transform_filter(label),\n", - " \n", - " data=stocks\n", - ").properties(\n", - " width=700,\n", - " height=400\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Data Tables\n", - "\n", - "You can display tables per the usual way in your blog:" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
TitleWorldwide_GrossProduction_BudgetIMDB_Rating
0The Land Girls146083.08000000.06.1
1First Love, Last Rites10876.0300000.06.9
2I Married a Strange Person203134.0250000.06.8
3Let's Talk About Sex373615.0300000.0NaN
4Slam1087521.01000000.03.4
\n", - "
" - ], - "text/plain": [ - " Title Worldwide_Gross Production_Budget IMDB_Rating\n", - "0 The Land Girls 146083.0 8000000.0 6.1\n", - "1 First Love, Last Rites 10876.0 300000.0 6.9\n", - "2 I Married a Strange Person 203134.0 250000.0 6.8\n", - "3 Let's Talk About Sex 373615.0 300000.0 NaN\n", - "4 Slam 1087521.0 1000000.0 3.4" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "movies = 'https://vega.github.io/vega-datasets/data/movies.json'\n", - "df = pd.read_json(movies)\n", - "# display table with pandas\n", - "df[['Title', 'Worldwide_Gross', \n", - " 'Production_Budget', 'IMDB_Rating']].head()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Other Feautures" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Images w/Captions\n", - "\n", - "You can include markdown images with captions like this:\n", - "\n", - "```\n", - "![](https://www.fast.ai/images/fastai_paper/show_batch.png \"Credit: https://www.fast.ai/2020/02/13/fastai-A-Layered-API-for-Deep-Learning/\")\n", - "```\n", - "\n", - "\n", - "![](https://www.fast.ai/images/fastai_paper/show_batch.png \"Credit: https://www.fast.ai/2020/02/13/fastai-A-Layered-API-for-Deep-Learning/\")\n", - "\n", - "Of course, the caption is optional." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Tweetcards\n", - "\n", - "Typing `> twitter: https://twitter.com/jakevdp/status/1204765621767901185?s=20` will render this:\n", - "\n", - "> twitter: https://twitter.com/jakevdp/status/1204765621767901185?s=20" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Youtube Videos\n", - "\n", - "Typing `> youtube: https://youtu.be/XfoYk_Z5AkI` will render this:\n", - "\n", - "\n", - "> youtube: https://youtu.be/XfoYk_Z5AkI" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Boxes / Callouts \n", - "\n", - "Typing `> Warning: There will be no second warning!` will render this:\n", - "\n", - "\n", - "> Warning: There will be no second warning!\n", - "\n", - "\n", - "\n", - "Typing `> Important: Pay attention! It's important.` will render this:\n", - "\n", - "> Important: Pay attention! It's important.\n", - "\n", - "\n", - "\n", - "Typing `> Tip: This is my tip.` will render this:\n", - "\n", - "> Tip: This is my tip.\n", - "\n", - "\n", - "\n", - "Typing `> Note: Take note of this.` will render this:\n", - "\n", - "> Note: Take note of this.\n", - "\n", - "\n", - "\n", - "Typing `> Note: A doc link to [an example website: fast.ai](https://www.fast.ai/) should also work fine.` will render in the docs:\n", - "\n", - "> Note: A doc link to [an example website: fast.ai](https://www.fast.ai/) should also work fine." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## More Examples\n", - "\n", - "This [tutorial](https://fastpages.fast.ai/fastpages/jupyter/2020/02/20/test.html) contains more examples of what you can do with notebooks. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How fastpages Converts Notebooks to Blog Posts" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "fastpages uses [nbdev](https://nbdev.fast.ai/index.html) to power the conversion process of Jupyter Notebooks to blog posts. When you save a notebook into the `/_notebooks` folder of your repository, GitHub Actions applies `nbdev` against those notebooks automatically. The same process occurs when you save Word documents or markdown files into the `_word` or `_posts` directory, respectively.\n", - "\n", - "We will discuss how GitHub Actions work in a follow up blog post." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources & Next Steps" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We highly encourage you to start blogging with `fastpages`! Some resources that may be helpful:\n", - "\n", - "- [fastpages repo](https://github.com/fastai/fastpages) - this is where you can go to create your own fastpages blog!\n", - "- Fastai forums - [nbdev & blogging category](https://forums.fast.ai/c/fastai-users/nbdev/). You can ask questions about fastpages here, as well as suggest new features.\n", - "- [nbdev](https://github.com/fastai/nbdev): this project powers the conversion of Jupyter notebooks to blog posts.\n", - "\n", - "If you end up writing a blog post using fastpages, please let us know on Twitter: [@jeremyphoward](https://twitter.com/jeremyphoward), [@HamelHusain](https://twitter.com/hamelhusain)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_posts/2020-03-06-fastpages-actions.md b/_posts/2020-03-06-fastpages-actions.md deleted file mode 100644 index 489ad95..0000000 --- a/_posts/2020-03-06-fastpages-actions.md +++ /dev/null @@ -1,282 +0,0 @@ ---- -title: "GitHub Actions: Providing Data Scientists With New Superpowers" -description: "A Tutorial on GitHub Actions For Data Scientists" -toc: true -comments: true -layout: post -categories: [actions, markdown] -image: images/fastpages_posts/actions/actions_logo.png -author: Hamel Husain & Jeremy Howard ---- - -# What Superpowers? - -Hi, I'm [Hamel Husain](https://twitter.com/HamelHusain). I'm a machine learning engineer at GitHub. Recently, GitHub released a new product called [GitHub Actions](https://github.com/features/actions), which has mostly flown under the radar in the machine learning and data science community as just another continuous integration tool. - -Recently, I've been able to use GitHub Actions to build some very unique tools for Data Scientists, which I want to share with you today. Most importantly, I hope to get you excited about GitHub Actions, and the promise it has for giving you new superpowers as a Data Scientist. Here are two projects I recently built with Actions that show off its potential: - -## fastpages - -[fastpages](https://github.com/fastai/fastpages) is an automated, open-source blogging platform with enhanced support for Jupyter notebooks. You save your notebooks, markdown, or Word docs into a directory on GitHub, and they automatically become blog posts. Read the announcement below: - - - -## Machine Learning Ops - -Wouldn't it be cool if you could invoke a chatbot natively on GitHub to test your machine learning models on the infrastructure of your choice (GPUs), log all the results, and give you a rich report back in a pull request so that everyone could see the results? You can with GitHub Actions! - -Consider the below annotated screenshot of [this Pull Request](https://github.com/machine-learning-apps/actions-ml-cicd/pull/34): - -![](/images/fastpages_posts/actions/pr_1.png) -![](/images/fastpages_posts/actions/pr_2.png) - -A more in-depth explanation about the above project can be viewed in this video: - -{% include youtube.html content="https://youtu.be/Ll50l3fsoYs" %} - -Using GitHub Actions for machine learning workflows is starting to catch on. [Julien Chaumond](https://twitter.com/julien_c), CTO of [Hugging Face](https://huggingface.co/), says: - -> GitHub Actions are great because they let us do CI on GPUs (as most of our users use the library on GPUs not on CPUs), on our own infra! [^1] - -Additionally, you can host a GitHub Action for other people so others can use parts of your workflow without having to re-create your steps. I provide examples of this below. - -# A Gentle Introduction To GitHub Actions - -## What Are GitHub Actions? - -[GitHub Actions](https://github.com/features/actions) allow you to run arbitrary code in response to [events](https://help.github.com/en/actions/reference/events-that-trigger-workflows). Events are activities that happen on GitHub such as: - -- Opening a pull request -- Making an issue comment -- Labeling an issue -- Creating a new branch -- ... [and many more](https://help.github.com/en/actions/reference/events-that-trigger-workflows) - -When an event is created, the GitHub Actions context is hydrated with a [payload](https://developer.github.com/v3/activity/events/types/) containing metadata for that event. Below is an example of a payload that is received when an issue is created: - -{% raw %} - -```json -{ - "action": "created", - "issue": { - "id": 444500041, - "number": 1, - "title": "Spelling error in the README file", - "user": { - "login": "Codertocat", - "type": "User", - }, - "labels": [ - { - "id": 1362934389, - "node_id": "MDU6TGFiZWwxMzYyOTM0Mzg5", - "name": "bug", - } - ], - "body": "It looks like you accidently spelled 'commit' with two 't's." -} -``` - -This functionality allows you to respond to various events on GitHub in an automated way. In addition to this payload, GitHub Actions also provide a plethora [of variables](https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#github-context) and [environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) that afford easy to access metadata such as the username and the owner of the repo. Additionally, other people can package useful functionality into an Action that other people can inherit. For example, consider the below Action that helps you [publish python packages to PyPi](https://github.com/pypa/gh-action-pypi-publish): - -The [Usage](https://github.com/pypa/gh-action-pypi-publish#usage) section describes how this Action can be used: - -```yaml -- name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} -``` - -This Action expects two inputs: `user` and a `password`. You will notice that the password is referencing a variable called `secrets`, which is a variable that contains an [encrypted secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) that you can upload to your GitHub repository. There are thousands of Actions (that are free) for a wide variety of tasks that can be discovered on the [GitHub Marketplace](https://github.com/marketplace?type=actions). The ability to inherit ready-made Actions in your workflow allows you to accomplish complex tasks without implementing all of the logic yourself. Some useful Actions for those getting started are: - -- [actions/checkout](https://github.com/actions/checkout): Allows you to quickly clone the contents of your repository into your environment, which you often want to do. This does a number of other things such as automatically mount your repository’s files into downstream Docker containers. -- [mxschmitt/action-tmate](https://github.com/mxschmitt/action-tmate): Proivdes a way to debug Actions interactively. This uses port forwarding to give you a terminal in the browser that is connected to your Actions runner. Be careful not to expose sensitive information if you use this. -- [actions/github-script](https://github.com/actions/github-script): Gives you a pre-authenticated [ocotokit.js](https://octokit.github.io/rest.js/) client that allows you to interact with the GitHub API to accomplish almost any task on GitHub automatically. Only [these endpoints](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token) are supported (for example, the [secrets endpoint](https://developer.github.com/v3/actions/secrets/) is not in that list). - -In addition to the aforementioned Actions, it is helpful to go peruse the official [GitHub Actions docs](https://help.github.com/en/actions) before diving in. - -## Example: A fastpages Action Workflow - -The best to way familiarize yourself with Actions is by studying examples. Let’s take a look at the Action workflow that automates the build of [fastpages](https://fastpages.fast.ai/fastpages/jupyter/2020/02/21/introducing-fastpages.html) (the platform used to write this blog post). - -### Part 1: Define Workflow Triggers - - blog, [defined in ci.yaml](https://github.com/fastai/fastpages/blob/master/.github/workflows/ci.yaml). Like all Actions workflows, this is YAML file is located in the .github/workflows directory of the GitHub repo. - -The top of this YAML file looks like this: - -```yaml -name: CI -on: - push: - branches: - - master - pull_request: -``` - -This means that this workflow is triggered on either a [push](https://help.github.com/en/actions/reference/events-that-trigger-workflows#push-event-push) or [pull request](https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request) event. Furthermore, push events are filtered such that only pushes to the master branch will trigger the workflow, whereas all pull requests will trigger this workflow. It is important to note that pull requests opened from forks will have read-only access to the base repository and cannot access any secrets for security reasons. The reason for defining the workflow in this way is we wanted to trigger the same workflow to test pull requests as well as build and deploy the website when a PR is merged into master. This will be clarified as we step through the rest of the YAML file. - -### Part 2: Define Jobs - -Next, we define jobs (there is only one in this workflow). Per [the docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobs): - -> A workflow run is made up of one or more jobs. Jobs run in parallel by default. - -```yaml -jobs: - build-site: - if: ( github.event.commits[0].message != 'Initial commit' ) || github.run_number > 1 - runs-on: ubuntu-latest - steps: -``` - -The keyword `build-site` is the name of your job and you can name it whatever you want. In this case, we have a conditional if statement that dictates if this job should be run or not. We are trying to ensure that this workflow does not run when the first commit to a repo is made with the message ‘Initial commit’. The first variable in the if statement, [github.event](https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#github-context), contains a [json payload](https://developer.github.com/v3/activity/events/types/#webhook-payload-example-31) of the event that triggered this workflow. When developing workflows, it is helpful to print this variable in order to inspect its structure, which you can accomplish with the following YAML: - -```yaml - - name: see payload - run: | - echo "PAYLOAD:\n${PAYLOAD}\n" - env: - PAYLOAD: ${{ toJSON(github.event) }} -``` -_Note: the above step is only for debugging and is not currently in the workflow._ - -[toJson](https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#tojson) is a handy function that returns a pretty-printed JSON representation of the variable. The output is printed directly in the logs contained in the Actions tab of your repo. In this example, printing the payload for a push event will look like this (truncated for brevity): - -```json -{ - "ref": "refs/tags/simple-tag", - "before": "6113728f27ae8c7b1a77c8d03f9ed6e0adf246", - "created": false, - "deleted": true, - "forced": false, - "base_ref": null, - "commits": [ - { - "message": "updated README.md", - "author": "hamelsmu" - }, - ], - "head_commit": null, -} -``` - -Therefore, the variable `github.event.commits[0].message` will retrieve the first commit message in the array of commits. Since we are looking for situations where there is only one commit, this logic suffices. The second variable in the if statement, [github.run_number](https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#github-context) is a special variable in Actions which: - -> [is a] unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run. - -Therefore, the `if` statement introduced above: -```yaml -if: ( github.event.commits[0].message != 'Initial commit' ) || github.run_number > 1 -``` - -Allows the workflow to run when the commit message is “Initial commit” as long as it is not the first commit. ( `||` is a logical `or` operator). - -Finally, the line `runs-on: ubuntu-latest` specifies the [host operating system](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on) that your workflows will run in. - -### Part 3: Define Steps - -Per the [docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idsteps): - -> A job contains a sequence of tasks called steps. Steps can run commands, run setup tasks, or run an Action in your repository, a public repository, or an Action published in a Docker registry. Not all steps run Actions, but all Actions run as a step. Each step runs in its own process in the runner environment and has access to the workspace and filesystem. Because steps run in their own process, changes to environment variables are not preserved between steps. GitHub provides built-in steps to set up and complete a job. - -Below are the first two steps [in our workflow](https://github.com/fastai/fastpages/blob/master/.github/workflows/ci.yaml): - -```yaml - - name: Copy Repository Contents - uses: actions/checkout@master - with: - persist-credentials: false - - - name: convert notebooks and word docs to posts - uses: ./_action_files -``` - -The first step creates a copy of your repository in the Actions file system, with the help of the utility [action/checkout](https://github.com/actions/checkout). This utility only fetches the last commit by default and saves files into a directory (whose path is stored in the environment variable [GITHUB_WORKSPACE](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables) that is accessible by subsequent steps in your job. The second step runs the [fastai/fastpages](https://github.com/fastai/fastpages#using-the-github-action--your-own-custom-blog) Action, which converts notebooks and word documents to blog posts automatically. In this case, the syntax: - -```yaml -uses: ./_action_files -``` - -is a special case where the pre-made GitHub Action we want to run happens to be defined in the same repo that runs this workflow. This syntax allows us to test changes to this pre-made Action when evaluating PRs by referencing the directory in the current repository that defines that pre-made Action. _Note: Building pre-made Actions is beyond the scope of this tutorial._ - -The next three steps in our workflow are defined below: - -```yaml - - 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" - 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 || : -``` - -The step named `setup directories for Jekyll build` executes shell commands that remove the `_site` folder in order to get rid of stale files related to the page we want to build, as well as grant permissions to all the files in our repo to subsequent steps. - -The step named `Jekyll build` executes a docker container hosted by the Jekyll community [on Dockerhub called `jekyll/jekyll`](https://hub.docker.com/r/jekyll/jekyll/). For those not familiar with Docker, see [this tutorial](https://towardsdatascience.com/how-docker-can-help-you-become-a-more-effective-data-scientist-7fc048ef91d5?source=friends_link&sk=c554b55109102d47145c4b3381bee3ee). The name of this container is called `hamelsmu/fastpages-jekyll` because I'm adding some additional dependencies to `jekyll/jekyll` and hosting those on my DockerHub account for faster build times[^2]. The [args parameter](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswithargs) allows you to execute arbitrary commands with the Docker container by overriding the CMD instruction in the Dockerfile. We use this Docker container hosted on Dockerhub so we don’t have to deal with installing and configuring all of the complicated dependencies for Jekyll. The files from our repo are already available in the Actions runtime due to the first step in this workflow, and are mounted into this Docker container automatically for us. In this case, we are running the command `jekyll build`, which builds our website and places relevant assets them into the `_site` folder. For more information about Jekyll, [read the official docs](https://jekyllrb.com/docs/). Finally, the `env` parameter allows me to pass an environment variable into the Docker container. - -The final command above copies a `CNAME` file into the _site folder, which we need for the custom domain [https://fastpages.fast.ai](https://fastpages.fast.ai/). Setting up custom domains are outside the scope of this article. - -The final step in our workflow is defined below: - -```yaml - - name: Deploy - if: github.event_name == 'push' - uses: peaceiris/actions-gh-pages@v3 - with: - deploy_key: ${{ secrets.SSH_DEPLOY_KEY }} - publish_dir: ./_site -``` - -{% endraw %} - -The statement -```yaml -if: github.event_name == 'push' -``` -uses the variable [github.event_name](https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#github-context) to ensure this step only runs when a push event ( in this case only pushes to the master branch trigger this workflow) occur. - -This step deploys the fastpages website by copying the contents of the `_site` folder to the root of the `gh-pages` branch, which [GitHub Pages](https://pages.github.com/) uses for hosting. This step uses the [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) Action, pinned at version 3. [Their README](https://github.com/peaceiris/actions-gh-pages) describes various options and inputs for this Action. - -# Conclusion - -We hope that this has shed some light on how we use GitHub Actions to automate fastpages. While we only covered one workflow above, we hope this provides enough intuition to understand the [other workflows](https://github.com/fastai/fastpages/tree/master/.github/workflows) in fastpages. We have only scratched the surface of GitHub Actions in this blog post, but we provide other materials below for those who want to dive in deeper. We have not covered how to host an Action for other people, but you can [start with these docs](https://help.github.com/en/actions/building-actions) to learn more. - -Still confused about how GitHub Actions could be used for Data Science? Here are some ideas of things you can build: - -- Jupyter Widgets that trigger GitHub Actions to perform various tasks on GitHub via the [repository dispatch event](https://help.github.com/en/actions/reference/events-that-trigger-workflows#external-events-repository_dispatch) -- Integration with [Pachyderm](https://www.pachyderm.com/) for data versioning. -- Integration with your favorite cloud machine learning services, such [Sagemaker](https://aws.amazon.com/sagemaker/), [Azure ML](https://azure.microsoft.com/en-us/free/machine-learning/) or GCP's [AI Platform](https://cloud.google.com/ai-platform). - -## Related Materials - -- GitHub Actions official [documentation](https://help.github.com/en/actions) -- [Hello world Docker Action](https://github.com/actions/hello-world-docker-action): A template to demonstrate how to build a Docker Action for other people to use. -- [Awesome Actions](https://github.com/sdras/awesome-actions): A curated list of interesting GitHub Actions by topic. -- [A tutorial on Docker](https://towardsdatascience.com/how-docker-can-help-you-become-a-more-effective-data-scientist-7fc048ef91d5?source=friends_link&sk=c554b55109102d47145c4b3381bee3ee) for Data Scientists. - -### Getting In Touch - -Please feel free to get in touch with us on Twitter: - -- Hamel Husain [@HamelHusain](https://twitter.com/HamelHusain) -- Jeremy Howard [@jeremyphoward](https://twitter.com/jeremyphoward) - -___ -##### Footnotes - -[^1]: You can see some of Hugging Face's Actions workflows for machine learning [on GitHub](https://github.com/huggingface/transformers/tree/master/.github/workflows) -[^2]: These additional dependencies are [defined here](https://github.com/fastai/fastpages/blob/master/_action_files/fastpages-jekyll.Dockerfile), which uses the "jekyll build" command to add ruby dedpendencies from the Gemfile located at the root of the repo. Additionally, this docker image is built by another Action workflow [defined here](https://github.com/fastai/fastpages/blob/master/.github/workflows/docker.yaml). diff --git a/_word/2020-01-01-Microsoft-Word-Example-Post.docx b/_word/2020-01-01-Microsoft-Word-Example-Post.docx deleted file mode 100644 index c58f9bf..0000000 Binary files a/_word/2020-01-01-Microsoft-Word-Example-Post.docx and /dev/null differ diff --git "a/_word/2020-04-13-\346\254\242\350\277\216\357\274\210MS Word\357\274\211.docx" "b/_word/2020-04-13-\346\254\242\350\277\216\357\274\210MS Word\357\274\211.docx" deleted file mode 100644 index 7016fae..0000000 Binary files "a/_word/2020-04-13-\346\254\242\350\277\216\357\274\210MS Word\357\274\211.docx" and /dev/null differ diff --git "a/_word/2020-04-14-fastpages\346\261\211\345\214\226\347\211\210\344\275\277\347\224\250\350\257\264\346\230\216.docx" "b/_word/2020-04-14-fastpages\346\261\211\345\214\226\347\211\210\344\275\277\347\224\250\350\257\264\346\230\216.docx" deleted file mode 100644 index 7eef118..0000000 Binary files "a/_word/2020-04-14-fastpages\346\261\211\345\214\226\347\211\210\344\275\277\347\224\250\350\257\264\346\230\216.docx" and /dev/null differ diff --git a/action.yml b/action.yml deleted file mode 100644 index 8fd3e1a..0000000 --- a/action.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: 'fastpages: An easy to use blogging platform with support for Jupyter Notebooks.' -description: Converts Jupyter notebooks and Word docs into Jekyll blog posts. -author: Hamel Husain -inputs: - BOOL_SAVE_MARKDOWN: - description: Either 'true' or 'false'. Whether or not to commit converted markdown files from notebooks and word documents into the _posts directory in your repo. This is useful for debugging. - required: false - default: false - SSH_DEPLOY_KEY: - description: a ssh deploy key is required if BOOL_SAVE_MARKDOWN = 'true' - required: false -branding: - color: 'blue' - icon: 'book' -runs: - using: 'docker' - image: '_action_files/Dockerfile' diff --git a/images/fastpages_posts/actions/actions_logo.png b/images/fastpages_posts/actions/actions_logo.png deleted file mode 100644 index e3c5650..0000000 Binary files a/images/fastpages_posts/actions/actions_logo.png and /dev/null differ diff --git a/images/fastpages_posts/actions/pr_1.png b/images/fastpages_posts/actions/pr_1.png deleted file mode 100644 index c6c1fd2..0000000 Binary files a/images/fastpages_posts/actions/pr_1.png and /dev/null differ diff --git a/images/fastpages_posts/actions/pr_2.png b/images/fastpages_posts/actions/pr_2.png deleted file mode 100644 index 6f93c08..0000000 Binary files a/images/fastpages_posts/actions/pr_2.png and /dev/null differ