From f0a4207d859136da950e045a469827eabda096d4 Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Fri, 17 Nov 2023 14:45:22 +0900 Subject: [PATCH 1/4] Add script to update dojo stats --- _data/stats.yml | 2 ++ update_profile.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 _data/stats.yml create mode 100755 update_profile.rb diff --git a/_data/stats.yml b/_data/stats.yml new file mode 100644 index 0000000..0a77479 --- /dev/null +++ b/_data/stats.yml @@ -0,0 +1,2 @@ +--- +active_dojos: 180 diff --git a/update_profile.rb b/update_profile.rb new file mode 100755 index 0000000..7d9d032 --- /dev/null +++ b/update_profile.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require 'net/http' +require 'json' +require 'yaml' + +BASE_URL = 'https://coderdojo.jp' +DOJO_STATS = JSON.parse Net::HTTP.get(URI.parse "#{BASE_URL}/stats.json"), symbolize_names: true +STATS_PATH = '_data/stats.yml' + +stats = YAML.load_file(STATS_PATH) +stats['active_dojos'] = DOJO_STATS[:active_dojos] +YAML.dump stats, File.open(STATS_PATH, 'w') From 89b0d9dbcae5712197afb3e598112424d1d052b8 Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Fri, 17 Nov 2023 14:45:29 +0900 Subject: [PATCH 2/4] Show latest dojo stats at top page via _data/stats.yml --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 503af36..a263855 100644 --- a/index.html +++ b/index.html @@ -192,7 +192,7 @@

DojoCon Japan とは?

CoderDojo とは?

-

CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、日本には180以上の道場があります。

+

CoderDojo は7〜17歳を対象とした非営利のプログラミング道場です。2011年にアイルランドで始まり、世界では100カ国・2,000の道場、日本には{{ site.data.stats['active_dojos'] }}以上の道場があります。

From 0f3bfca0e45129e09ec7fa80d6e62f757d9f5c40 Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Fri, 17 Nov 2023 14:48:17 +0900 Subject: [PATCH 3/4] Add step to exec: bundle install --- .github/workflows/test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83d08de..a1a8733 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,10 @@ jobs: with: bundler-cache: true + - name: 🧪 Install gems + run: | + bundle install + - name: 🔧 Build & Test run: | JEKYLL_ENV=test bundle exec jekyll build @@ -49,8 +53,6 @@ jobs: - name: 🧪 Install gems run: | - bundle config set with 'test' - bundle config set path 'vendor/bundle' bundle install - name: 🔧 Build From 930301a54c5e103382518c3f5b9c38f951deed6f Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Fri, 17 Nov 2023 14:49:07 +0900 Subject: [PATCH 4/4] Add scheduler_daily.yml to Actions --- .github/workflows/scheduler_daily.yml | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/scheduler_daily.yml diff --git a/.github/workflows/scheduler_daily.yml b/.github/workflows/scheduler_daily.yml new file mode 100644 index 0000000..f4ee59f --- /dev/null +++ b/.github/workflows/scheduler_daily.yml @@ -0,0 +1,69 @@ +name: Daily Update + +# NOTE: GitHub Action's scheduler is always set to UTC+0. So 9am should be set at 0am for JST (UTC+9) +# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule + +# '0 23 * * *' == 8am in JST (UTC+9) +# '0 0 * * *' == 9am in JST (UTC+9) +# '0 1 * * *' == 10am in JST (UTC+9) +# '59 23 * * *' task will be completed after 9am in JST +on: + schedule: + - cron: '59 20 * * *' + + # [DEBUG ONLY] Every 5 minutes + # https://github.blog/changelog/2019-11-01-github-actions-scheduled-jobs-maximum-frequency-is-changing + #- cron: '*/5 * * * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: 📥 Download codes from GitHub + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: 💎 Set up Ruby + uses: ruby/setup-ruby@v1 + #with: + # bundler-cache: true + #ruby-version: 3.2 # Not necessary if .ruby-version is given + + - name: 🧪 Install Ruby gems + run: | + bundle install + + - name: 📊 Update dojo stats of Japan + run: | + bundle exec ruby update_profile.rb + + - name: 🆙 Update profile if updated + run: | + if [ -n "$(git status --porcelain)" ]; then + git config --global user.name "Yohei Yasukawa" + git config --global user.email "yohei@yasslab.jp" + git checkout main + git add _data/stats.yml + git commit -m '🤖 Update dojo stats' + git push origin main + fi + env: + GITHUB_TOKEN: + + - name: 🔧 Build & Test + run: | + JEKYLL_ENV=production bundle exec jekyll build + JEKYLL_ENV=production bundle exec jekyll doctor + SKIP_BUILD=true bundle exec rake test + + - name: 🚀 Deploy to GitHub Pages + if: github.ref == 'refs/heads/main' && job.status == 'success' + uses: peaceiris/actions-gh-pages@v3 + with: + personal_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy