Skip to content

Commit 6ec6c1a

Browse files
authored
Merge pull request #46 from vim-jp/build-and-deploy-renewal
new workflow trial
2 parents e76b667 + d9fda1a commit 6ec6c1a

File tree

15 files changed

+896
-8
lines changed

15 files changed

+896
-8
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and deploy vim help
2+
3+
# This is an experimental.
4+
#
5+
# gh-pagesブランチを経由せず、actions/upload-pages-artifactを使って直接GitHub Pagesにデプロイする試み
6+
# pushのたびにいったん artifacts まで作る(HTML生成+Jekyll実行)
7+
# masterへのpushかcronでの実行であればGitHub Pagesへアップロードする
8+
# …という計画
9+
10+
on:
11+
push:
12+
13+
schedule:
14+
- cron: '5 12 * * *'
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-24.04
19+
steps:
20+
- name: Setup Vim
21+
uses: thinca/action-setup-vim@v2
22+
with:
23+
vim_version: 'v9.1.0065'
24+
vim_type: 'Vim'
25+
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
#
30+
# Generate HTML from Vim documents and upload it as an artifact.
31+
#
32+
33+
- name: Generate new HTML documents
34+
run: |
35+
make html
36+
37+
- name: Check commit IDs
38+
id: commitid
39+
run: |
40+
echo "vim=$(git -C vim rev-parse HEAD)" >> $GITHUB_OUTPUT
41+
echo "vim_faq=$(git -C vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT
42+
43+
- name: Upload vim generated HTML files as an artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: vim-generated-html
47+
path: target/html/doc/*.html
48+
49+
#
50+
# Generate GitHub Page site and upload it as an artifact.
51+
#
52+
53+
- name: Prepare for building GitHub Page (Jekyll)
54+
run:
55+
make jekyll-build-prepare
56+
57+
- name: Build GitHub Page site
58+
uses: actions/jekyll-build-pages@v1
59+
with:
60+
source: target/jekyll-work
61+
verbose: true
62+
63+
- name: Upload a site as an artifact
64+
uses: actions/upload-pages-artifact@v3
65+
with:
66+
path: _site/
67+
retention-days: 7
68+
69+
# Upload a site to GitHub Pages
70+
deploy:
71+
needs:
72+
- build
73+
environment:
74+
name: github-pages
75+
url: ${{ steps.deployment.outputs.page_url }}
76+
runs-on: ubuntu-22.04
77+
permissions:
78+
contents: read
79+
pages: write
80+
id-token: write
81+
# Run only when updating the master branch or when started by cron.
82+
if: github.ref == 'refs/heads/master' || github.event_name == 'schedule'
83+
steps:
84+
- name: Deploy to Github Pages
85+
id: deployment
86+
uses: actions/deploy-pages@v4

.github/workflows/generate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: |
4545
echo "vim=$(git -C work/vim rev-parse HEAD)" >> $GITHUB_OUTPUT
4646
echo "vim_faq=$(git -C work/vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT
47-
- name: Commit updated master branch
47+
- name: Commit updated gh-pages branch
4848
uses: EndBug/add-and-commit@v9
4949
with:
5050
cwd: './target'

.github/workflows/trigger.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ jobs:
1717
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
1818
-H "Accept: application/vnd.github.v3+json" \
1919
'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/trigger.yml/enable'
20+
curl -i -X PUT \
21+
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
22+
-H "Accept: application/vnd.github.v3+json" \
23+
'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/build-and-deploy.yml/enable'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/target/
55
/vim/
66
/vim_faq/
7+
/tmp/

Makefile

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
11
.PHONY: all html clean
22

3+
JEKYLL_WORKDIR=target/jekyll-work
4+
JEKYLL_OUTDIR=target/_site
5+
36
all:
7+
$(MAKE) html
8+
$(MAKE) jekyl-build-by-docker
9+
10+
html-prepare: vim/runtime/doc vim_faq/doc target/html/doc
11+
rm -f target/html/doc/*.txt
12+
cp vim/runtime/doc/*.txt target/html/doc
13+
cp vim_faq/doc/*.txt target/html/doc
414

5-
html:
6-
rm -rf target/html
7-
mkdir -p target/html/doc
8-
if [ ! -d vim/runtime/doc ]; then git clone --depth=1 https://github.com/vim/vim.git; fi
9-
if [ ! -d vim_faq/doc ]; then git clone --depth=1 https://github.com/chrisbra/vim_faq.git; fi
10-
cd vim; git apply ../tools/add-vimfaq-link.diff; cd ..
11-
cp vim/runtime/doc/*.txt vim_faq/doc/*.txt target/html/doc
15+
html: html-prepare
1216
-cd target/html/doc ; vim -eu ../../../tools/buildhtml.vim -c "qall!"
1317

18+
vim/runtime/doc:
19+
git clone --depth=1 https://github.com/vim/vim.git
20+
cd vim && git apply ../tools/add-vimfaq-link.diff
21+
22+
vim_faq/doc:
23+
git clone --depth=1 https://github.com/chrisbra/vim_faq.git
24+
25+
target/html/doc:
26+
mkdir -p $@
27+
1428
clean:
1529
rm -rf target
30+
31+
distclean: clean
32+
rm -rf vim vim_faq
33+
34+
jekyll-build-prepare:
35+
mkdir -p $(JEKYLL_WORKDIR)
36+
cp target/html/doc/*.html $(JEKYLL_WORKDIR)
37+
cp -Ru src/* $(JEKYLL_WORKDIR)
38+
39+
jekyll-build: jekyll-build-prepare
40+
jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR)
41+
42+
jekyll-build-by-docker: jekyll-build-prepare
43+
./tools/docker_jekyll jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR)
44+
45+
jekyll-clean:
46+
rm -rf $(JEKYLL_WORKDIR) $(JEKYLL_OUTDIR)
47+
48+
.PHONY: jekyll-build-prepare jekyll-build jekyll-build-by-docker jekyll-clean

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,16 @@ There is already another similar site: <https://vimhelp.org/>.
66
The main purpose of the vimdoc-en project is to provide a handy way to see both Japanese and English versions of the help pages.
77

88
The help pages are automatically updated everyday (if there are any changes).
9+
10+
## for Developers
11+
12+
First of all, to generate everything, just run `make`.
13+
This requires Docker, so prepare it in advance.
14+
15+
Here's what's happening:
16+
17+
1. Run `make html` to generate HTML files before GitHub Pages (Jekyll) processing
18+
1. Download vim and vim\_faq
19+
2. Collect the necessary \*.txt files
20+
3. Convert the \*.txt files to \*.html
21+
2. Run `make jekyll-build-by-docker` to output all HTML files for the vimdoc-en site using GitHub Pages (Jekyll)

src/_config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# 原則 http://jekyllrb.com/docs/configuration/#default-configuration からの
3+
# 差分のみ記述している。記述順序も前述に従う。
4+
5+
### Handling Reading
6+
# デフォルトと同じだが「utf-8で記事を書こう」という宣言的な意味合で残した。
7+
encoding: utf-8
8+
9+
### Filtering Content
10+
future: true
11+
12+
### Outputting
13+
# デフォルトと同じだが、万が一デフォルトが変わってしまうと記事のURLが変わってし
14+
# まいクリティカルなので、明示的に指定した。
15+
permalink: date
16+
17+
### Markdown Processors
18+
kramdown:
19+
input: GFM
20+
21+
############################################################################
22+
# 以下はvim-jp固有の設定項目
23+
24+
# baseurl と紛らわしいが別物なので要注意
25+
base-url: http://vim-jp.org/vimdoc-en

src/_includes/google-analytics.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
4+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
6+
7+
ga('create', 'UA-85527418-4', 'auto');
8+
ga('send', 'pageview');
9+
10+
</script>

0 commit comments

Comments
 (0)