-
-
Notifications
You must be signed in to change notification settings - Fork 3
132 lines (111 loc) · 4.38 KB
/
scheduler_daily.yml
File metadata and controls
132 lines (111 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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@v4
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: 🌐 Fetch dojo data from Earth
run: |
bundle exec rake get_data_from_earth
if [ "`cat tmp/number_of_dojos`" -lt "1000" ] ; then
echo "ERROR: NUMBER_OF_DOJOS=`cat tmp/number_of_dojos`"
echo "This number should be 1000+. Something went wrong."
exit 1
fi
- name: 🗾 Fetch dojo/event data from Japan
run: |
bundle exec rake get_data_from_japan
- name: 🔧 Build data to render DojoMap
run: |
# Jekyll plugin automatically runs cache_dojo_logos, upsert_dojos_geojson, and compact_geojson
JEKYLL_ENV=production bundle exec jekyll build
- name: ✅ Test
run: |
# _site is already built in previous step
JEKYLL_ENV=production bundle exec jekyll doctor
SKIP_BUILD=true bundle exec rake test
- name: 🆙 Commit latest data to update DojoMap (if any)
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
# Gems may update automatically
git add Gemfile.lock
# Cache responses from Japan/Clubs APIs
git add _data/*.json
git add images/dojos
# Save GeoJSON data to render DojoMap
git add dojos.geojson
# Commit changed files above
git commit -m '🤖 Upsert Earth/Japan data for DojoMap'
# Git pull/push the commit to deploy
git pull origin main
git push origin main
fi
env:
GITHUB_TOKEN:
# This is NOT for security reason but for others, especially who fork,
# to easier find out which API key they need to replace with their own.
# Check out the official tutorial for details: https://docs.geolonia.com/tutorial
- name: 🔑 Pass Geolonia YOUR-API-KEY from secrets
env:
GEOLONIA_API_KEY: ${{ secrets.GEOLONIA_API_KEY }}
run: |
ruby -i -pe '$_.gsub!("geolonia-api-key=YOUR-API-KEY",
"geolonia-api-key=${{ env.GEOLONIA_API_KEY }}")' _site/index.html
ruby -i -pe '$_.gsub!("geolonia-api-key=YOUR-API-KEY",
"geolonia-api-key=${{ env.GEOLONIA_API_KEY }}")' _site/world.html
- name: 🚀 Deploy to GitHub Pages
if: github.ref == 'refs/heads/main' && job.status == 'success'
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
- name: 🔔 Notify error to Slack (if any)
if: failure()
id: slack
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
# For posting a simple plain text message
payload: |
{
"text": "<@yasulab> Failed to build DojoMap. (詳細を見る)",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<@yasulab> Failed to build DojoMap. (<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|詳細を見る>)"
}
}
]
}