From 8d4c5556386512eb134c172e321b32ebaf8eb3b8 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:12:20 +0800 Subject: [PATCH] Fix gh-actions cache not being hit issue (#191) --- .github/workflows/ci.yml | 4 +- .github/workflows/pages-deploy.yml.hook | 6 +- .gitignore | 3 +- Gemfile | 4 +- Gemfile.lock | 111 ++++++++++++++++++++++++ tools/deploy.sh | 10 +++ 6 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 Gemfile.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ef3fe8..93e2dd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,13 @@ jobs: - name: Setup Ruby uses: actions/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: 2.7 - name: Bundle Caching uses: actions/cache@v2 with: path: ${{ env.GEMS_PATH }} - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }} + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | ${{ runner.os }}-gems- diff --git a/.github/workflows/pages-deploy.yml.hook b/.github/workflows/pages-deploy.yml.hook index 77aa297..4a57ea5 100644 --- a/.github/workflows/pages-deploy.yml.hook +++ b/.github/workflows/pages-deploy.yml.hook @@ -25,13 +25,13 @@ jobs: - name: Setup Ruby uses: actions/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: 2.7 - name: Bundle Caching uses: actions/cache@v2 with: path: ${{ env.GEMS_PATH }} - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }} + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | ${{ runner.os }}-gems- @@ -65,7 +65,7 @@ jobs: else bash tools/test.sh fi - + - name: Deploy run: | bash tools/deploy.sh diff --git a/.gitignore b/.gitignore index a76e045..ed798ee 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .* !.github -# jekyll cache +# jekyll cache _site -Gemfile.lock vendor diff --git a/Gemfile b/Gemfile index 8a8821c..db23cc8 100644 --- a/Gemfile +++ b/Gemfile @@ -6,13 +6,13 @@ gem "jekyll", ">= 3.8.6", "< 5.0" group :jekyll_plugins do gem "jekyll-paginate" gem "jekyll-redirect-from" - gem "jekyll-seo-tag", "~> 2.6.1" + gem "jekyll-seo-tag" gem "jekyll-archives" gem "jekyll-sitemap" end group :test do - gem "html-proofer", "~> 3.16.0" + gem "html-proofer" end # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..89d2f1e --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,111 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + colorator (1.1.0) + concurrent-ruby (1.1.7) + em-websocket (0.5.2) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0.6.0) + ethon (0.12.0) + ffi (>= 1.3.0) + eventmachine (1.2.7) + ffi (1.13.1) + forwardable-extended (2.6.0) + html-proofer (3.17.4) + addressable (~> 2.3) + mercenary (~> 0.3) + nokogumbo (~> 2.0) + parallel (~> 1.3) + rainbow (~> 3.0) + typhoeus (~> 1.3) + yell (~> 2.0) + http_parser.rb (0.6.0) + i18n (1.8.5) + concurrent-ruby (~> 1.0) + jekyll (4.1.1) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (~> 2.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (~> 0.4.0) + pathutil (~> 0.9) + rouge (~> 3.0) + safe_yaml (~> 1.0) + terminal-table (~> 1.8) + jekyll-archives (2.2.1) + jekyll (>= 3.6, < 5.0) + jekyll-paginate (1.1.0) + jekyll-redirect-from (0.16.0) + jekyll (>= 3.3, < 5.0) + jekyll-sass-converter (2.1.0) + sassc (> 2.0.1, < 3.0) + jekyll-seo-tag (2.7.1) + jekyll (>= 3.8, < 5.0) + jekyll-sitemap (1.4.0) + jekyll (>= 3.7, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + kramdown (2.3.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.3) + listen (3.3.3) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.4.0) + mini_portile2 (2.4.0) + nokogiri (1.10.10) + mini_portile2 (~> 2.4.0) + nokogumbo (2.0.4) + nokogiri (~> 1.8, >= 1.8.4) + parallel (1.20.1) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (4.0.6) + rainbow (3.0.0) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) + ffi (~> 1.0) + rexml (3.2.4) + rouge (3.25.0) + safe_yaml (1.0.5) + sassc (2.4.0) + ffi (~> 1.9) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thread_safe (0.3.6) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (1.2.8) + thread_safe (~> 0.1) + tzinfo-data (1.2020.4) + tzinfo (>= 1.0.0) + unicode-display_width (1.7.0) + wdm (0.1.1) + yell (2.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + html-proofer + jekyll (>= 3.8.6, < 5.0) + jekyll-archives + jekyll-paginate + jekyll-redirect-from + jekyll-seo-tag + jekyll-sitemap + tzinfo (~> 1.2) + tzinfo-data + wdm (~> 0.1.1) + +BUNDLED WITH + 2.1.4 diff --git a/tools/deploy.sh b/tools/deploy.sh index bdc6cd1..0a6353d 100755 --- a/tools/deploy.sh +++ b/tools/deploy.sh @@ -15,6 +15,16 @@ _no_branch=false _backup_dir="$(mktemp -d)" init() { + if [[ -z ${GITHUB_ACTION+x} ]]; then + echo "ERROR: This script is not allowed to run outside of GitHub Action." + exit -1 + fi + + # Gemfile could be changed by `bundle install` in actions workflow + if [[ -n $(git status Gemfile.lock --porcelain) ]]; then + git checkout -- Gemfile.lock + fi + if [[ -z $(git branch -av | grep "$PAGES_BRANCH") ]]; then _no_branch=true git checkout -b "$PAGES_BRANCH"