Skip to content

new workflow trial #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build and deploy vim help

# This is an experimental.
#
# gh-pagesブランチを経由せず、actions/upload-pages-artifactを使って直接GitHub Pagesにデプロイする試み
# pushのたびにいったん artifacts まで作る(HTML生成+Jekyll実行)
# masterへのpushかcronでの実行であればGitHub Pagesへアップロードする
# …という計画

on:
push:

schedule:
- cron: '5 12 * * *'

jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Setup Vim
uses: thinca/action-setup-vim@v2
with:
vim_version: 'v9.1.0065'
vim_type: 'Vim'

- name: Checkout
uses: actions/checkout@v4

#
# Generate HTML from Vim documents and upload it as an artifact.
#

- name: Generate new HTML documents
run: |
make html

- name: Check commit IDs
id: commitid
run: |
echo "vim=$(git -C vim rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "vim_faq=$(git -C vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Upload vim generated HTML files as an artifact
uses: actions/upload-artifact@v4
with:
name: vim-generated-html
path: target/html/doc/*.html

#
# Generate GitHub Page site and upload it as an artifact.
#

- name: Prepare for building GitHub Page (Jekyll)
run:
make jekyll-build-prepare

- name: Build GitHub Page site
uses: actions/jekyll-build-pages@v1
with:
source: target/jekyll-work
verbose: true

- name: Upload a site as an artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site/
retention-days: 7

# Upload a site to GitHub Pages
deploy:
needs:
- build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
permissions:
contents: read
pages: write
id-token: write
# Run only when updating the master branch or when started by cron.
if: github.ref == 'refs/heads/master' || github.event_name == 'schedule'
steps:
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
echo "vim=$(git -C work/vim rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "vim_faq=$(git -C work/vim_faq rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Commit updated master branch
- name: Commit updated gh-pages branch
uses: EndBug/add-and-commit@v9
with:
cwd: './target'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ jobs:
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
-H "Accept: application/vnd.github.v3+json" \
'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/trigger.yml/enable'
curl -i -X PUT \
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
-H "Accept: application/vnd.github.v3+json" \
'https://api.github.com/repos/vim-jp/vimdoc-en/actions/workflows/build-and-deploy.yml/enable'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/target/
/vim/
/vim_faq/
/tmp/
47 changes: 40 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
.PHONY: all html clean

JEKYLL_WORKDIR=target/jekyll-work
JEKYLL_OUTDIR=target/_site

all:
$(MAKE) html
$(MAKE) jekyl-build-by-docker

html-prepare: vim/runtime/doc vim_faq/doc target/html/doc
rm -f target/html/doc/*.txt
cp vim/runtime/doc/*.txt target/html/doc
cp vim_faq/doc/*.txt target/html/doc

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

vim/runtime/doc:
git clone --depth=1 https://github.com/vim/vim.git
cd vim && git apply ../tools/add-vimfaq-link.diff

vim_faq/doc:
git clone --depth=1 https://github.com/chrisbra/vim_faq.git

target/html/doc:
mkdir -p $@

clean:
rm -rf target

distclean: clean
rm -rf vim vim_faq

jekyll-build-prepare:
mkdir -p $(JEKYLL_WORKDIR)
cp target/html/doc/*.html $(JEKYLL_WORKDIR)
cp -Ru src/* $(JEKYLL_WORKDIR)

jekyll-build: jekyll-build-prepare
jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR)

jekyll-build-by-docker: jekyll-build-prepare
./tools/docker_jekyll jekyll build -s $(JEKYLL_WORKDIR) -d $(JEKYLL_OUTDIR)

jekyll-clean:
rm -rf $(JEKYLL_WORKDIR) $(JEKYLL_OUTDIR)

.PHONY: jekyll-build-prepare jekyll-build jekyll-build-by-docker jekyll-clean
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ There is already another similar site: <https://vimhelp.org/>.
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.

The help pages are automatically updated everyday (if there are any changes).

## for Developers

First of all, to generate everything, just run `make`.
This requires Docker, so prepare it in advance.

Here's what's happening:

1. Run `make html` to generate HTML files before GitHub Pages (Jekyll) processing
1. Download vim and vim\_faq
2. Collect the necessary \*.txt files
3. Convert the \*.txt files to \*.html
2. Run `make jekyll-build-by-docker` to output all HTML files for the vimdoc-en site using GitHub Pages (Jekyll)
25 changes: 25 additions & 0 deletions src/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
############################################################################
# 原則 http://jekyllrb.com/docs/configuration/#default-configuration からの
# 差分のみ記述している。記述順序も前述に従う。

### Handling Reading
# デフォルトと同じだが「utf-8で記事を書こう」という宣言的な意味合で残した。
encoding: utf-8

### Filtering Content
future: true

### Outputting
# デフォルトと同じだが、万が一デフォルトが変わってしまうと記事のURLが変わってし
# まいクリティカルなので、明示的に指定した。
permalink: date

### Markdown Processors
kramdown:
input: GFM

############################################################################
# 以下はvim-jp固有の設定項目

# baseurl と紛らわしいが別物なので要注意
base-url: http://vim-jp.org/vimdoc-en
10 changes: 10 additions & 0 deletions src/_includes/google-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-85527418-4', 'auto');
ga('send', 'pageview');

</script>
Loading