├── .github ├── FUNDING.yml └── workflows │ └── deploy-test.yml ├── .gitignore ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE.txt ├── README.md ├── action.yml ├── entrypoint.sh ├── providers ├── github.sh └── test.sh ├── script ├── cleanup_bundler.sh ├── init_environment.sh └── update_cache_key.sh └── test_site ├── 404.html ├── _config.yml ├── _posts └── 2020-07-01-welcome-to-jekyll.markdown ├── about.markdown └── index.markdown /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: jeffreytse # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: jeffreytse 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: jeffreytse 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: jeffreytse 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/workflows/deploy-test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | github-pages: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: actions/cache@v4 14 | with: 15 | path: | 16 | .asdf/** 17 | vendor/bundle 18 | key: ${{ runner.os }}-cache-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/cache.key') }} 19 | restore-keys: | 20 | ${{ runner.os }}-cache- 21 | - uses: ./ 22 | with: 23 | provider: 'github' 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | jekyll_src: './test_site' 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | build 3 | .sass-cache 4 | .jekyll-cache 5 | .jekyll-metadata 6 | vendor 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM archlinux:base-devel 2 | 3 | LABEL version="0.1.0" 4 | LABEL repository="https://github.com/jeffreytse/jekyll-deploy-action" 5 | LABEL homepage="https://github.com/jeffreytse/jekyll-deploy-action" 6 | LABEL maintainer="Jeffrey Tse " 7 | 8 | COPY LICENSE.txt README.md / 9 | 10 | COPY script /script 11 | COPY providers /providers 12 | COPY entrypoint.sh / 13 | 14 | ENTRYPOINT ["/entrypoint.sh"] 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | # Hello! This is where you manage which Jekyll version is used to run. 3 | # When you want to use a different version, change it below, save the 4 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: 5 | # 6 | # bundle exec jekyll serve 7 | # 8 | # This will help ensure the proper Jekyll version is running. 9 | # Happy Jekylling! 10 | gem "jekyll", "~> 4.1.0" 11 | # This is the default theme for new Jekyll sites. You may change this to anything you like. 12 | gem "minima", "~> 2.5" 13 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and 14 | # uncomment the line below. To upgrade, run `bundle update github-pages`. 15 | # gem "github-pages", group: :jekyll_plugins 16 | # If you have any plugins, put them here! 17 | group :jekyll_plugins do 18 | gem "jekyll-feed", "~> 0.12" 19 | gem 'jekyll-spaceship', '~> 0.6' 20 | end 21 | 22 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem 23 | # and associated library. 24 | platforms :mingw, :x64_mingw, :mswin, :jruby do 25 | gem "tzinfo", "~> 1.2" 26 | gem "tzinfo-data" 27 | end 28 | 29 | # Performance-booster for watching directories on Windows 30 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] 31 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.8.6) 5 | public_suffix (>= 2.0.2, < 6.0) 6 | colorator (1.1.0) 7 | concurrent-ruby (1.2.3) 8 | em-websocket (0.5.3) 9 | eventmachine (>= 0.12.9) 10 | http_parser.rb (~> 0) 11 | eventmachine (1.2.7) 12 | ffi (1.16.3) 13 | forwardable-extended (2.6.0) 14 | gemoji (3.0.1) 15 | http_parser.rb (0.8.0) 16 | i18n (1.14.4) 17 | concurrent-ruby (~> 1.0) 18 | jekyll (4.1.1) 19 | addressable (~> 2.4) 20 | colorator (~> 1.0) 21 | em-websocket (~> 0.5) 22 | i18n (~> 1.0) 23 | jekyll-sass-converter (~> 2.0) 24 | jekyll-watch (~> 2.0) 25 | kramdown (~> 2.1) 26 | kramdown-parser-gfm (~> 1.0) 27 | liquid (~> 4.0) 28 | mercenary (~> 0.4.0) 29 | pathutil (~> 0.9) 30 | rouge (~> 3.0) 31 | safe_yaml (~> 1.0) 32 | terminal-table (~> 1.8) 33 | jekyll-feed (0.17.0) 34 | jekyll (>= 3.7, < 5.0) 35 | jekyll-sass-converter (2.2.0) 36 | sassc (> 2.0.1, < 3.0) 37 | jekyll-seo-tag (2.8.0) 38 | jekyll (>= 3.8, < 5.0) 39 | jekyll-spaceship (0.10.2) 40 | gemoji (~> 3.0) 41 | jekyll (>= 3.6, < 5.0) 42 | nokogiri (~> 1.6) 43 | rainbow (~> 3.0) 44 | jekyll-watch (2.2.1) 45 | listen (~> 3.0) 46 | kramdown (2.4.0) 47 | rexml 48 | kramdown-parser-gfm (1.1.0) 49 | kramdown (~> 2.0) 50 | liquid (4.0.4) 51 | listen (3.9.0) 52 | rb-fsevent (~> 0.10, >= 0.10.3) 53 | rb-inotify (~> 0.9, >= 0.9.10) 54 | mercenary (0.4.0) 55 | mini_portile2 (2.8.8) 56 | minima (2.5.1) 57 | jekyll (>= 3.5, < 5.0) 58 | jekyll-feed (~> 0.9) 59 | jekyll-seo-tag (~> 2.1) 60 | nokogiri (1.18.8) 61 | mini_portile2 (~> 2.8.2) 62 | racc (~> 1.4) 63 | nokogiri (1.18.8-aarch64-linux-gnu) 64 | racc (~> 1.4) 65 | nokogiri (1.18.8-arm-linux-gnu) 66 | racc (~> 1.4) 67 | nokogiri (1.18.8-arm64-darwin) 68 | racc (~> 1.4) 69 | nokogiri (1.18.8-x86_64-darwin) 70 | racc (~> 1.4) 71 | nokogiri (1.18.8-x86_64-linux-gnu) 72 | racc (~> 1.4) 73 | pathutil (0.16.2) 74 | forwardable-extended (~> 2.6) 75 | public_suffix (5.0.4) 76 | racc (1.8.1) 77 | rainbow (3.1.1) 78 | rb-fsevent (0.11.2) 79 | rb-inotify (0.10.1) 80 | ffi (~> 1.0) 81 | rexml (3.3.9) 82 | rouge (3.30.0) 83 | safe_yaml (1.0.5) 84 | sassc (2.4.0) 85 | ffi (~> 1.9) 86 | terminal-table (1.8.0) 87 | unicode-display_width (~> 1.1, >= 1.1.1) 88 | unicode-display_width (1.8.0) 89 | 90 | PLATFORMS 91 | aarch64-linux 92 | arm-linux 93 | arm64-darwin 94 | x86-linux 95 | x86_64-darwin 96 | x86_64-linux 97 | 98 | DEPENDENCIES 99 | jekyll (~> 4.1.0) 100 | jekyll-feed (~> 0.12) 101 | jekyll-spaceship (~> 0.6) 102 | minima (~> 2.5) 103 | tzinfo (~> 1.2) 104 | tzinfo-data 105 | wdm (~> 0.1.1) 106 | 107 | BUNDLED WITH 108 | 2.5.7 109 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Jeffrey Tse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | jekyll-theme-yat →~ jekyll 6 | 7 | 8 |

🪂 A GitHub Action to deploy the Jekyll site conveniently for GitHub Pages.

9 | 10 |
11 | 12 |

JEKYLL DEPLOY ACTION

13 | 14 |
15 | 16 |

17 | Jekyll action for deployment. 18 |

19 | 20 |

21 | 22 | 23 | Tests 25 | 26 | 27 | 28 | Release Version 30 | 31 | 32 | 33 | License: MIT 35 | 36 | 37 | 38 | Donate (Liberapay) 40 | 41 | 42 | 43 | Donate (Patreon) 45 | 46 | 47 | 48 | Donate (Ko-fi) 50 | 51 | 52 |

53 | 54 |
55 | Built with ❤︎ by 56 | jeffreytse and 57 | contributors 58 |
59 | 60 | ## ✨ Story 61 | 62 | As we known, GitHub Pages runs in `safe` mode and a [set of allow-listed plugins](https://pages.github.com/versions/). To use the gem in GitHub Pages, you need to build locally or use CI (e.g. [travis](https://travis-ci.org/), [github workflow](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow)) and deploy to your `gh-pages` branch. 63 | 64 | **Therefore, if you want to make Jekyll site run as if it were local, such as let 65 | the custom plugins work properly, this action can be very useful for you, 66 | beacause it's really convenient to build and deploy the Jekyll site to Github 67 | Pages.** 68 | 69 | ## 📚 Usage 70 | 71 | At First, you should add a github workflow file (e.g. `.github/workflows/build-jekyll.yml`) in your repository's `master` branch as below: 72 | 73 | ```yml 74 | name: Build and Deploy to Github Pages 75 | 76 | on: 77 | push: 78 | branches: 79 | - master # Here source code branch is `master`, it could be other branch 80 | 81 | jobs: 82 | build_and_deploy: 83 | runs-on: ubuntu-latest 84 | steps: 85 | - uses: actions/checkout@v4 86 | 87 | # Use GitHub Actions' cache to cache dependencies on servers 88 | - uses: actions/cache@v4 89 | with: 90 | path: | 91 | .asdf/** 92 | vendor/bundle 93 | key: ${{ runner.os }}-cache-${{ hashFiles('**/cache.key') }} 94 | restore-keys: | 95 | ${{ runner.os }}-cache- 96 | 97 | # Use GitHub Deploy Action to build and deploy to Github 98 | # For latest version: `jeffreytse/jekyll-deploy-action@master` 99 | - uses: jeffreytse/jekyll-deploy-action@v0.6.0 100 | with: 101 | provider: 'github' # Default is github 102 | token: ${{ secrets.GITHUB_TOKEN }} # It's your Personal Access Token(PAT) 103 | ssh_private_key: '' # It's your SSH private key (SSH approach) 104 | repository: '' # Default is current repository 105 | branch: 'gh-pages' # Default is gh-pages for github provider 106 | jekyll_src: './' # Default is root directory 107 | jekyll_cfg: '_config.yml' # Default is _config.yml 108 | jekyll_baseurl: '' # Default is according to _config.yml 109 | ruby_ver: '' # Default is 3.2.0 version 110 | bundler_ver: '' # Default is compatible bundler version (~>2.5.0) 111 | cname: '' # Default is to not use a cname 112 | actor: '' # Default is the GITHUB_ACTOR 113 | pre_build_commands: '' # Installing additional dependencies (Arch Linux) 114 | ``` 115 | 116 | Now this action supports the following providers: 117 | 118 | - [x] `github`: To publish the site to GitHub. 119 | - [x] `test`: To check if build passes on pull requests without publishing the site. 120 | - [ ] `ssh`: To publish the site into any server which supports SSH protocol. 121 | - ... 122 | 123 | To schedule a workflow, you can use the POSIX cron syntax in your workflow file. 124 | The shortest interval you can run scheduled workflows is once every 5 minutes. 125 | For example, this workflow is triggered every hour. 126 | 127 | ```yml 128 | on: 129 | schedule: 130 | - cron: '0 * * * *' 131 | ``` 132 | 133 | At the start of each workflow run, GitHub automatically creates a unique 134 | `GITHUB_TOKEN` secret to use in your workflow. You can use the `GITHUB_TOKEN` 135 | to authenticate in a workflow run. You can use the `GITHUB_TOKEN` by using the 136 | standard syntax for referencing secrets: `${{ secrets.GITHUB_TOKEN }}`. For 137 | more information, you can see [here](https://docs.github.com/en/actions/security-guides/automatic-token-authentication). 138 | 139 | If you need a token that requires permissions that aren't available in the 140 | `GITHUB_TOKEN`, you can create a Personal Access Token (PAT), and set it as 141 | a secret in your repository for this action to push to the `gh-pages` branch: 142 | 143 | - Create a [Personal Access Token](https://github.com/settings/tokens) with custom permissions and copy the value. 144 | - Go to your repository’s Settings and then switch to the Secrets tab. 145 | - Create a token named `GH_TOKEN` (important) using the value copied. 146 | 147 | In the end, go to your repository’s Settings and scroll down to the GitHub Pages 148 | section, choose the `gh-pages` branch as your GitHub Pages source. 149 | 150 | Additionally, if you don't have the `gh-pages` branch, you can create it as below: 151 | 152 | ```bash 153 | git checkout --orphan gh-pages 154 | git rm -rf . 155 | git commit --allow-empty -m "initial commit" 156 | git push origin gh-pages 157 | ``` 158 | 159 | **💡 Tip:** The `gh-pages` branch is only for the site static files and the `master` branch is for source code. 160 | 161 | ## ✨ FAQ 162 | 163 | If you use [jekyll-last-modified-at](https://github.com/gjtorikian/jekyll-last-modified-at) plugin, you can configure the checkout action to fetch all commit history so that plugin could use the last Git commit date to determine a page's last modified date. 164 | 165 | ```yaml 166 | - uses: actions/checkout@v3 167 | with: 168 | # The checkout action doesn't provide a way to get all commit history for a single branch 169 | # So we use the magic number 2147483647 here which means infinite depth for git fetch 170 | # See https://github.com/actions/checkout/issues/520, https://stackoverflow.com/a/6802238 171 | fetch-depth: 2147483647 172 | ``` 173 | 174 | If your site building needs some specific environments, here are some recipes 175 | for you: 176 | 177 | ```yaml 178 | # NodeJS 179 | pre_build_commands: pacman -S --noconfirm nodejs npm 180 | 181 | # Python 182 | pre_build_commands: pacman -S --noconfirm python 183 | 184 | # Gem RMagick 185 | pre_build_commands: pacman -S --noconfirm imagemagick 186 | 187 | # Jekyll-Picture-Tag 188 | pre_build_commands: pacman -S --noconfirm libvips lcms2 openjpeg2 libpng libwebp libheif imagemagick openslide libjxl poppler-glib 189 | ``` 190 | 191 | If you prefer to deploy your site in SSH approach for better stability, you can 192 | also creates a unique `SSH_PRIVATE_KEY` secret to use in your workflow: 193 | 194 | ```yml 195 | ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} 196 | ``` 197 | 198 | __Note:__ SSH approach has higher priority than HTTP approach when you provide 199 | both at the same time. 200 | 201 | ## 🌱 Credits 202 | 203 | - [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby. 204 | - [actions/checkout](https://github.com/actions/checkout) - Action for checking out a repo. 205 | - [actions/cache](https://github.com/actions/cache) - Cache dependencies and build outputs in GitHub Actions. 206 | 207 | ## ✍️ Contributing 208 | 209 | Issues and Pull Requests are greatly appreciated. If you've never contributed to an open source project before I'm more than happy to walk you through how to create a pull request. 210 | 211 | You can start by [opening an issue](https://github.com/jeffreytse/jekyll-deploy-action/issues/new) describing the problem that you're looking to resolve and we'll go from there. 212 | 213 | ## 🌈 License 214 | 215 | This software is licensed under the [MIT license](https://opensource.org/licenses/mit-license.php) © JeffreyTse. 216 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Jekyll Deploy Action' 2 | description: > 3 | 🪂 A Github Action to deploy the Jekyll site conveniently for GitHub Pages 4 | inputs: 5 | provider: 6 | description: 'The deploy provider' 7 | required: true 8 | token: 9 | description: 'The deploy token' 10 | required: false 11 | ssh_private_key: 12 | description: 'The SSH private key for using SSH approach' 13 | required: false 14 | repository: 15 | description: 'The deploy repository' 16 | required: false 17 | branch: 18 | description: 'The deploy branch' 19 | required: false 20 | actor: 21 | description: 'The github username creating the commit' 22 | required: false 23 | cname: 24 | description: 'The cname to use for the site' 25 | required: false 26 | ruby_ver: 27 | description: 'The Ruby version' 28 | required: false 29 | bundler_ver: 30 | description: 'The Bundler version' 31 | required: false 32 | jekyll_src: 33 | description: 'The Jekyll website source directory' 34 | required: false 35 | jekyll_cfg: 36 | description: 'The Jekyll website config files' 37 | required: false 38 | jekyll_baseurl: 39 | description: 'The Jekyll website baseurl' 40 | required: false 41 | pre_build_commands: 42 | description: 'The pre-build commands' 43 | required: false 44 | runs: 45 | using: 'docker' 46 | image: 'Dockerfile' 47 | branding: 48 | icon: 'command' 49 | color: 'red' 50 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Get script directory 5 | SCRIPT_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 6 | WORKING_DIR=${PWD} 7 | 8 | # Initial default value 9 | PROVIDER=${INPUT_PROVIDER:=github} 10 | TOKEN=${INPUT_TOKEN} 11 | SSH_PRIVATE_KEY=${INPUT_SSH_PRIVATE_KEY:=} 12 | ACTOR=${INPUT_ACTOR} 13 | REPOSITORY=${INPUT_REPOSITORY} 14 | BRANCH=${INPUT_BRANCH} 15 | RUBY_VER=${INPUT_RUBY_VER:=3.2.0} 16 | BUNDLER_VER=${INPUT_BUNDLER_VER:=~>2.5.0} 17 | JEKYLL_SRC=${INPUT_JEKYLL_SRC:=./} 18 | JEKYLL_CFG=${INPUT_JEKYLL_CFG:=./_config.yml} 19 | JEKYLL_BASEURL=${INPUT_JEKYLL_BASEURL:=} 20 | PRE_BUILD_COMMANDS=${INPUT_PRE_BUILD_COMMANDS:=} 21 | 22 | # Set default bundle path and cache 23 | BUNDLE_PATH=${WORKING_DIR}/vendor/bundle 24 | 25 | echo "Starting the Jekyll Deploy Action" 26 | 27 | if [[ "${PROVIDER}" != "test" ]]; then 28 | # Check if the token or SSH private key is set 29 | if [[ -z "${TOKEN}" && -z "${SSH_PRIVATE_KEY}" ]]; then 30 | echo "Please set the TOKEN or SSH_PRIVATE_KEY environment variable." 31 | exit 1 32 | fi 33 | fi 34 | 35 | # Check parameters and assign default values 36 | if [[ "${PROVIDER}" == "github" ]]; then 37 | : ${ACTOR:=${GITHUB_ACTOR}} 38 | : ${REPOSITORY:=${GITHUB_REPOSITORY}} 39 | : ${BRANCH:=gh-pages} 40 | 41 | # Check if repository is available 42 | if ! echo "${REPOSITORY}" | grep -Eq ".+/.+"; then 43 | echo "The repository ${REPOSITORY} doesn't match the pattern /" 44 | exit 1 45 | fi 46 | 47 | # Fix Github API metadata warnings 48 | export JEKYLL_GITHUB_TOKEN=${TOKEN} 49 | fi 50 | 51 | # Initialize environment 52 | echo "Initialize environment" 53 | source ${SCRIPT_DIR}/script/init_environment.sh 54 | 55 | cd ${JEKYLL_SRC} 56 | 57 | # Check and execute pre_build_commands commands 58 | if [[ ${PRE_BUILD_COMMANDS} ]]; then 59 | echo "Executing pre-build commands" 60 | eval "${PRE_BUILD_COMMANDS}" 61 | fi 62 | 63 | echo "Check bundler version from Gemfile.lock" 64 | GEMFILE_LOCK_DIR="${PWD}" 65 | while [[ "${GEMFILE_LOCK_DIR}" != "/" ]] && 66 | [[ ! -f "${GEMFILE_LOCK_DIR}/Gemfile.lock" ]]; do 67 | GEMFILE_LOCK_DIR="$(dirname "${GEMFILE_LOCK_DIR}")" 68 | done 69 | 70 | if [[ -f "${GEMFILE_LOCK_DIR}/Gemfile.lock" ]]; then 71 | BUNDLER_VER="$( \ 72 | grep -A 1 'BUNDLED WITH' "${GEMFILE_LOCK_DIR}/Gemfile.lock" | \ 73 | tail -n 1 | xargs)" 74 | echo "Bundler version ${BUNDLER_VER} is required by your Gemfile.lock!" 75 | fi 76 | 77 | echo "Initial comptible bundler" 78 | ${SCRIPT_DIR}/script/cleanup_bundler.sh 79 | gem install bundler -v "${BUNDLER_VER}" 80 | 81 | CLEANUP_BUNDLER_CACHE_DONE=false 82 | 83 | # Clean up bundler cache 84 | cleanup_bundler_cache() { 85 | echo "Cleaning up incompatible bundler cache" 86 | rm -rf ${BUNDLE_PATH} 87 | mkdir -p ${BUNDLE_PATH} 88 | CLEANUP_BUNDLER_CACHE_DONE=true 89 | } 90 | 91 | # If the vendor/bundle folder is cached in a differnt OS (e.g. Ubuntu), 92 | # it would cause `jekyll build` failed, we should clean up the uncompatible 93 | # cache firstly. 94 | OS_NAME_FILE=${BUNDLE_PATH}/os-name 95 | os_name=$(cat /etc/os-release | grep '^NAME=') 96 | os_name=${os_name:6:-1} 97 | 98 | if [[ "$os_name" != "$(cat $OS_NAME_FILE 2>/dev/null)" ]]; then 99 | cleanup_bundler_cache 100 | echo $os_name > $OS_NAME_FILE 101 | fi 102 | 103 | echo "Starting bundle install" 104 | bundle config cach_all true 105 | bundle config path $BUNDLE_PATH 106 | bundle install 107 | 108 | # Pre-handle Jekyll baseurl 109 | if [[ -n "${JEKYLL_BASEURL-}" ]]; then 110 | JEKYLL_BASEURL="--baseurl ${JEKYLL_BASEURL}" 111 | fi 112 | 113 | build_jekyll() { 114 | echo "Starting jekyll build" 115 | JEKYLL_ENV=production bundle exec jekyll build \ 116 | ${JEKYLL_BASEURL} \ 117 | -c ${JEKYLL_CFG} \ 118 | -d ${WORKING_DIR}/build 119 | } 120 | 121 | build_jekyll || { 122 | $CLEANUP_BUNDLER_CACHE_DONE && exit -1 123 | echo "Rebuild all gems and try to build again" 124 | cleanup_bundler_cache 125 | bundle install 126 | build_jekyll 127 | } 128 | 129 | # Pre-handle SSH private key 130 | if [[ -n "${SSH_PRIVATE_KEY}" ]]; then 131 | echo "Pre-handle SSH private key file" 132 | SSH_PRIVATE_KEY_PATH=$(mktemp /tmp/ssh-priv-key.XXXXXX) 133 | echo "${SSH_PRIVATE_KEY}" > ${SSH_PRIVATE_KEY_PATH} 134 | # To prevent from permissions are too open issue, the key can be 135 | # only readable by self 136 | chmod 400 ${SSH_PRIVATE_KEY_PATH} 137 | fi 138 | 139 | cd ${WORKING_DIR}/build 140 | 141 | # Check if deploy on the same repository branch 142 | PROVIDER_EXIT_CODE=0 143 | if [[ -f "${SCRIPT_DIR}/providers/${PROVIDER}.sh" ]]; then 144 | source "${SCRIPT_DIR}/providers/${PROVIDER}.sh" 145 | else 146 | echo "${PROVIDER} is an unsupported provider." 147 | PROVIDER_EXIT_CODE=1 148 | fi 149 | 150 | # Post-handle SSH private key 151 | if [[ -n "${SSH_PRIVATE_KEY}" ]]; then 152 | echo "Post-handle SSH private key file" 153 | rm -f ${SSH_PRIVATE_KEY_PATH} 154 | fi 155 | 156 | # Update cache key 157 | echo "Update cache key..." 158 | source ${SCRIPT_DIR}/script/update_cache_key.sh 159 | 160 | exit ${PROVIDER_EXIT_CODE} 161 | -------------------------------------------------------------------------------- /providers/github.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Check if deploy to same branch 5 | if [[ "${REPOSITORY}" = "${GITHUB_REPOSITORY}" ]]; then 6 | if [[ "${GITHUB_REF}" = "refs/heads/${BRANCH}" ]]; then 7 | echo "It's conflicted to deploy on same branch ${BRANCH}" 8 | exit 1 9 | fi 10 | fi 11 | 12 | # Tell GitHub Pages not to run Jekyll 13 | touch .nojekyll 14 | [[ -n "$INPUT_CNAME" ]] && echo "$INPUT_CNAME" > CNAME 15 | 16 | # Prefer to use SSH approach when SSH private key is provided 17 | if [[ -n "${SSH_PRIVATE_KEY}" ]]; then 18 | export GIT_SSH_COMMAND="ssh -i ${SSH_PRIVATE_KEY_PATH} \ 19 | -o StrictHostKeyChecking=no \ 20 | -o UserKnownHostsFile=/dev/null" 21 | REMOTE_REPO="git@github.com:${REPOSITORY}.git" 22 | else 23 | REMOTE_REPO="https://${ACTOR}:${TOKEN}@github.com/${REPOSITORY}.git" 24 | fi 25 | 26 | echo "Deploying to ${REPOSITORY} on branch ${BRANCH}" 27 | echo "Deploying to ${REMOTE_REPO}" 28 | 29 | git config --global init.defaultBranch main && \ 30 | git config --global http.postBuffer 524288000 && \ 31 | git init && \ 32 | git config user.name "${ACTOR}" && \ 33 | git config user.email "${ACTOR}@users.noreply.github.com" && \ 34 | git add . && \ 35 | git commit -m "jekyll build from Action ${GITHUB_SHA}" && \ 36 | git push --force $REMOTE_REPO main:$BRANCH && \ 37 | (fuser -k .git || rm -rf .git) && \ 38 | cd .. 39 | 40 | PROVIDER_EXIT_CODE=$? 41 | -------------------------------------------------------------------------------- /providers/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Print a simple test statement 5 | echo "This is just for deployment test." 6 | 7 | echo "File listing..." 8 | find . -type f 9 | 10 | PROVIDER_EXIT_CODE=$? 11 | -------------------------------------------------------------------------------- /script/cleanup_bundler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | gempaths = %x(gem env gempath).split(":") 4 | gempaths.each do |gempath| 5 | # lookup bundler-*.gemspec files and delete them 6 | # this is the only way to completely cleanup default bundler 7 | # Note: the bundler gemspecs' paths are different for CRuby and JRuby 8 | Dir.glob(gempath.strip + "/specifications/**/bundler-*.gemspec").each { |p| File.delete(p) } 9 | end 10 | 11 | -------------------------------------------------------------------------------- /script/init_environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Generate a default secret key 4 | # To prevent archlinux-keyring from no secret key available to sign with 5 | pacman-key --init 6 | 7 | # Update packages database 8 | pacman -Syu --noconfirm 9 | 10 | # Installing git package 11 | pacman -S --noconfirm git 12 | 13 | # Installing openssh package 14 | if [[ -n "${SSH_PRIVATE_KEY}" ]]; then 15 | pacman -S --noconfirm openssh 16 | fi 17 | 18 | # Install asdf-vm for tools' version management 19 | ASDF_HOME=${WORKING_DIR}/.asdf 20 | 21 | if [[ ! -f "${ASDF_HOME}/asdf.sh" ]]; then 22 | git clone https://github.com/asdf-vm/asdf.git \ 23 | ${ASDF_HOME} --branch v0.14.0 24 | fi 25 | 26 | source ${ASDF_HOME}/asdf.sh 27 | 28 | # Fix invalid cache to asdf tools' installation 29 | ln -s ${ASDF_HOME} ${HOME}/.asdf 30 | 31 | # Install ruby environment 32 | pacman -S --noconfirm libyaml 33 | 34 | # Manually specify the language version for C compilation for ruby-build 35 | # to avoid error when building ruby and building ruby extensions. 36 | # C23 by default in GCC15: https://gcc.gnu.org/gcc-15/changes.html#c 37 | export RUBY_CFLAGS="-std=gnu17" 38 | 39 | if ! asdf list ruby ${RUBY_VER} &>/dev/null; then 40 | # Clean up ruby environments avoiding unnecessary cache 41 | rm -rf ${ASDF_HOME}/installs/ruby 42 | asdf plugin add ruby 43 | asdf install ruby ${RUBY_VER} 44 | fi 45 | 46 | asdf global ruby ${RUBY_VER} 47 | 48 | # debug 49 | ruby -v && bundle version 50 | 51 | # This is a temporary workaround 52 | # See https://github.com/actions/checkout/issues/766 53 | git config --global --add safe.directory "*" 54 | -------------------------------------------------------------------------------- /script/update_cache_key.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CACHE_KEY_PATH=$HOME/cache.key 4 | 5 | function sha1sumx() { 6 | if [[ -f "$1" ]]; then 7 | echo $(sha1sum "$1")>> $CACHE_KEY_PATH 8 | fi 9 | } 10 | 11 | sha1sumx $(find "${WORKING_DIR}" -not -path "**/.asdf/**" -iname '**Gemfile.lock') 12 | sha1sumx ${HOME}/.tool-versions 13 | -------------------------------------------------------------------------------- /test_site/404.html: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /404.html 3 | layout: default 4 | --- 5 | 6 | 19 | 20 |
21 |

404

22 | 23 |

Page not found :(

24 |

The requested page could not be found.

25 |
26 | -------------------------------------------------------------------------------- /test_site/_config.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Jekyll! 2 | # 3 | # This config file is meant for settings that affect your whole blog, values 4 | # which you are expected to set up once and rarely edit after that. If you find 5 | # yourself editing this file very often, consider using Jekyll's data files 6 | # feature for the data you need to update frequently. 7 | # 8 | # For technical reasons, this file is *NOT* reloaded automatically when you use 9 | # 'bundle exec jekyll serve'. If you change this file, please restart the server process. 10 | # 11 | # If you need help with YAML syntax, here are some quick references for you: 12 | # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml 13 | # https://learnxinyminutes.com/docs/yaml/ 14 | # 15 | # Site settings 16 | # These are used to personalize your new site. If you look in the HTML files, 17 | # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. 18 | # You can create any custom variable you would like, and they will be accessible 19 | # in the templates via {{ site.myvariable }}. 20 | 21 | title: Your awesome title 22 | email: your-email@example.com 23 | description: >- # this means to ignore newlines until "baseurl:" 24 | Write an awesome description for your new site here. You can edit this 25 | line in _config.yml. It will appear in your document head meta (for 26 | Google search results) and in your feed.xml site description. 27 | baseurl: "/jekyll-deploy-action" # the subpath of your site, e.g. /blog 28 | url: "" # the base hostname & protocol for your site, e.g. http://example.com 29 | twitter_username: jekyllrb 30 | github_username: jekyll 31 | 32 | # Build settings 33 | theme: minima 34 | plugins: 35 | - jekyll-feed 36 | 37 | # Exclude from processing. 38 | # The following items will not be processed, by default. 39 | # Any item listed under the `exclude:` key here will be automatically added to 40 | # the internal "default list". 41 | # 42 | # Excluded items can be processed by explicitly listing the directories or 43 | # their entries' file path in the `include:` list. 44 | # 45 | # exclude: 46 | # - .sass-cache/ 47 | # - .jekyll-cache/ 48 | # - gemfiles/ 49 | # - Gemfile 50 | # - Gemfile.lock 51 | # - node_modules/ 52 | # - vendor/bundle/ 53 | # - vendor/cache/ 54 | # - vendor/gems/ 55 | # - vendor/ruby/ 56 | -------------------------------------------------------------------------------- /test_site/_posts/2020-07-01-welcome-to-jekyll.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: "Welcome to Jekyll!" 4 | date: 2020-07-01 18:53:57 +0800 5 | categories: jekyll update 6 | --- 7 | You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. 8 | 9 | Jekyll requires blog post files to be named according to the following format: 10 | 11 | `YEAR-MONTH-DAY-title.MARKUP` 12 | 13 | Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works. 14 | 15 | Jekyll also offers powerful support for code snippets: 16 | 17 | {% highlight ruby %} 18 | def print_hi(name) 19 | puts "Hi, #{name}" 20 | end 21 | print_hi('Tom') 22 | #=> prints 'Hi, Tom' to STDOUT. 23 | {% endhighlight %} 24 | 25 | Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk]. 26 | 27 | [jekyll-docs]: https://jekyllrb.com/docs/home 28 | [jekyll-gh]: https://github.com/jekyll/jekyll 29 | [jekyll-talk]: https://talk.jekyllrb.com/ 30 | -------------------------------------------------------------------------------- /test_site/about.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: About 4 | permalink: /about/ 5 | --- 6 | 7 | This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/) 8 | 9 | You can find the source code for Minima at GitHub: 10 | [jekyll][jekyll-organization] / 11 | [minima](https://github.com/jekyll/minima) 12 | 13 | You can find the source code for Jekyll at GitHub: 14 | [jekyll][jekyll-organization] / 15 | [jekyll](https://github.com/jekyll/jekyll) 16 | 17 | 18 | [jekyll-organization]: https://github.com/jekyll 19 | -------------------------------------------------------------------------------- /test_site/index.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | # Feel free to add content and custom Front Matter to this file. 3 | # To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults 4 | 5 | layout: home 6 | --- 7 | --------------------------------------------------------------------------------