From 6398338fdf83327b6ef09d88f9bdaf5f15a1f0f1 Mon Sep 17 00:00:00 2001 From: Agah Date: Tue, 12 Oct 2021 11:35:01 -0400 Subject: [PATCH 01/11] Create requirements.txt --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..170c0a9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +markdown +xml +yaml +pandas +shutil +pybtex From 22582b09991e46492be783fa378793202939a128 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:09:02 -0400 Subject: [PATCH 02/11] sketch --- .github/workflows/build.yaml | 26 ++++++++++++++++++++++++++ .gitignore | 1 + code/build.py | 7 ++++--- requirements.txt | 6 +++--- 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..3ee9dba --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,26 @@ +name: Build-blog +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + name: Python ${{ matrix.python-version }} sample + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - name: Install requirements and build + run: | + pip install -r requirements.txt + python3 ./code/build.py + - name: Deploy + - uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.PAT_BLOG }} + publish_dir: ./_build \ No newline at end of file diff --git a/.gitignore b/.gitignore index 90df1e3..104928d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ # Distribution / packaging .Python build/ +_build/ develop-eggs/ dist/ downloads/ diff --git a/code/build.py b/code/build.py index c9c99dc..507a9da 100644 --- a/code/build.py +++ b/code/build.py @@ -8,9 +8,9 @@ import shutil # Source directory is the repository based -sourceDir = os.path.dirname(os.path.dirname(__file__)) +sourceDir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..')) # Build directory can be set here optionally - defaults to html in repository -buildDir = '/Users/jdiedrichsen/Dropbox (Diedrichsenlab)/Sites/Diedrichsenlab/BrainDataScience' +buildDir = os.path.join(sourceDir,'_build') if not os.path.exists(buildDir): buildDir = os.path.join(sourceDir,'html') if not os.path.exists(buildDir): @@ -121,7 +121,8 @@ def main(): shutil.copy2(source,target) # Build all the blogs in the list - with open("list.yaml", "r", encoding="utf-8") as list_file: + ymlFile = os.path.join(sourceDir,'list.yaml') + with open(ymlFile, "r", encoding="utf-8") as list_file: listing = yaml.load(list_file,Loader=yaml.FullLoader) info = [] for blog in listing['blogs']: diff --git a/requirements.txt b/requirements.txt index 170c0a9..efb838c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ markdown -xml +markdown-include +python-xml yaml pandas -shutil -pybtex +pybtex \ No newline at end of file From 8eb8f1e1c86266db2f7000c0b7fa5688a0ee0cc8 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:11:48 -0400 Subject: [PATCH 03/11] add hypen --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3ee9dba..c72e4a0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: python-version: ${{ matrix.python-version }} architecture: x64 - name: Install requirements and build - run: | + - run: | pip install -r requirements.txt python3 ./code/build.py - name: Deploy From eb2770133a95fc6720ad34170255e90742f6a9f9 Mon Sep 17 00:00:00 2001 From: Agah Date: Tue, 12 Oct 2021 12:13:12 -0400 Subject: [PATCH 04/11] Update build.yaml --- .github/workflows/build.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c72e4a0..2a0bfc2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,7 +7,6 @@ on: jobs: build: runs-on: ubuntu-latest - name: Python ${{ matrix.python-version }} sample steps: - uses: actions/checkout@v2 - name: Setup python @@ -16,11 +15,11 @@ jobs: python-version: ${{ matrix.python-version }} architecture: x64 - name: Install requirements and build - - run: | + run: | pip install -r requirements.txt python3 ./code/build.py - name: Deploy - - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.PAT_BLOG }} - publish_dir: ./_build \ No newline at end of file + publish_dir: ./_build From 87f085fe0eface683a15b73ab63da779fc93d040 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:14:51 -0400 Subject: [PATCH 05/11] typo --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index efb838c..a01f776 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ markdown markdown-include -python-xml +xml-python yaml pandas pybtex \ No newline at end of file From c652450d3a36855c116b00d7b931b80e253b2399 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:16:13 -0400 Subject: [PATCH 06/11] typo --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a01f776..d181a6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ markdown markdown-include xml-python -yaml +pyyaml pandas pybtex \ No newline at end of file From 24ecc9c25130d426cba12e8d5a4ac2ab3e3c32a0 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:19:11 -0400 Subject: [PATCH 07/11] mng dir --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a0bfc2..cbeea2c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,8 +18,9 @@ jobs: run: | pip install -r requirements.txt python3 ./code/build.py + ls ./_build - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.PAT_BLOG }} - publish_dir: ./_build + publish_dir: _build From 079d8d9146357dc4e9545b150105fad9756f54ee Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:21:15 -0400 Subject: [PATCH 08/11] mng dir --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cbeea2c..3d64ff4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,7 +18,8 @@ jobs: run: | pip install -r requirements.txt python3 ./code/build.py - ls ./_build + echo $PWD + ls - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: From 315e431f762b7f3c9f8a3711f41c8eeb5e669208 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:24:02 -0400 Subject: [PATCH 09/11] mng dir --- .github/workflows/build.yaml | 5 ++--- code/build.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3d64ff4..40b1de8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,10 +18,9 @@ jobs: run: | pip install -r requirements.txt python3 ./code/build.py - echo $PWD - ls + ls ./build - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.PAT_BLOG }} - publish_dir: _build + publish_dir: ./_build diff --git a/code/build.py b/code/build.py index 507a9da..69d548c 100644 --- a/code/build.py +++ b/code/build.py @@ -12,7 +12,7 @@ # Build directory can be set here optionally - defaults to html in repository buildDir = os.path.join(sourceDir,'_build') if not os.path.exists(buildDir): - buildDir = os.path.join(sourceDir,'html') + buildDir = os.path.join(sourceDir,'_build') if not os.path.exists(buildDir): os.makedirs(buildDir) From d9cc246d43134c5b47240275b97bc4d8f44ce8c7 Mon Sep 17 00:00:00 2001 From: Agah Karakuzu Date: Tue, 12 Oct 2021 12:24:59 -0400 Subject: [PATCH 10/11] mng dir --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 40b1de8..63a5e88 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: run: | pip install -r requirements.txt python3 ./code/build.py - ls ./build + ls ./_build - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: From 6c080784ef6e82345eaebbde9c59e24035f13f60 Mon Sep 17 00:00:00 2001 From: Agah Date: Tue, 12 Oct 2021 12:38:05 -0400 Subject: [PATCH 11/11] Update README.md --- README.md | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5cf5c6c..d01154e 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,41 @@ # BrainDataScienceBlog This is a repository with the code and raw materials to build the [*Brain, Data, and Science*](http://diedrichsenlab.org/BrainDataScience) Blog. It is heavily build on the [Tufte.css](https://edwardtufte.github.io/tufte-css/) and the [markdown library](https://python-markdown.github.io/). -## Installation +## Automatic GH-pages deployment + +### Step-0 Fork this repository ⑂ + +### Step-1 Create a GitHub access token 🔑 + +Please follow [these instructions](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token#creating-a-token) to create an access token. While creating the token, you will only click the `repository` checkbox. + +### Step-2 Create an encrypted secret for your repo 😎 + +Simply follow [these steps](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to create a **repository secret named `PAT_BLOG`**. + +### Step-3 That's it! + +If a secret is added successfully, a webpage build will be run by GitHub actions automatically and the webpage will be published online at: `your_gh_user_name.github.io/BrainDataScienceBlog` (unless you change the repository name). + +You can test the build by simply changing the README file (remove the last line etc.). When you add more content following the [writing a new blog section](#writing-a-new-blog), those pages will be built automatically and added to your webpage! + +## Local Installation Fork or clone the [GitHub repository](https://github.com/DiedrichsenLab/BrainDataScienceBlog). -The repro required `python v >= 3.8`. You also need to have the following dependencies installed: +The repro required `python v >= 3.6`. You also need to have the following dependencies installed: ``` -pip install markdown -pip install xml -pip install yaml -pip install pandas -pip install shutil -pip intall pybtex +pip install -r requirements.txt ``` -## Building the webpage +## Building the webpage manually + +A single Markdown file can be compiled to the target (`_build`) directory using: -A single Markdown file can be compiled to the target directory using: +`python3 ./code/build.py` -`python3 build.py` +If the build succeeds, you can see the webpage by opening `_build/index.htm` in your web browser. ## Writing a new blog