-
-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (109 loc) · 5 KB
/
ci.yaml
File metadata and controls
134 lines (109 loc) · 5 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
133
134
name: MacVim Documentation Build
on:
push:
schedule:
- cron: "50 3 * * *" # 3:50 am UTC every day. Just a random time intentionally picked to be not during busy hours.
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
env:
MACVIM_REPO: 'macvim-dev/macvim'
MACVIM_DIR: ${{ format('{0}/macvim', github.workspace) }}
jobs:
# Build the page and upload it as an artifact
build:
runs-on: ubuntu-latest
outputs:
docs_commit: ${{ steps.setup-env-vars.outputs.docs_commit }}
macvim_commit: ${{ steps.setup-env-vars.outputs.macvim_commit }}
macvim_commit_cache_hit: ${{ steps.restore-cache-macvim-commit.outputs.cache-hit }}
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Checkout MacVim
uses: actions/checkout@v6
with:
repository: ${{ env.MACVIM_REPO }}
path: 'macvim'
- name: Set up commit / version environmental vars
id: setup-env-vars
run: |
printf 'docs_commit=%s\n' $(git rev-parse HEAD) >> $GITHUB_OUTPUT
cd "$MACVIM_DIR"
printf 'MACVIM_COMMIT=%s\n' $(git rev-parse HEAD) >> $GITHUB_ENV
printf 'MACVIM_VERSION=%s\n' $(${GITHUB_WORKSPACE}/scripts/extract_macvim_version ./src) >> $GITHUB_ENV
printf 'VIM_VERSION=%s\n' $(${GITHUB_WORKSPACE}/scripts/extract_vim_version ./src) >> $GITHUB_ENV
printf 'macvim_commit=%s\n' $(git rev-parse HEAD) >> $GITHUB_OUTPUT
# We cache the last built commit info, so that we could choose not to
# deploy if we have already built this version already. This is useful to
# prevent the daily workflow stomping previously generated versions.
# Useful for preserving browser caching.
# We do make an exception for manual dispatch as that usually means we
# want to re-built the page.
- name: Check cached version info to see if current commit has been built before
id: restore-cache-macvim-commit
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: actions/cache/restore@v5
with:
path: ${{ github.workspace }}/macvim-built-commit.txt
key: macvim-built-commit-${{ steps.setup-env-vars.outputs.docs_commit}}-${{ steps.setup-env-vars.outputs.macvim_commit }}
- uses: actions/setup-python@v6
with:
python-version: '3.x'
cache: 'pip'
cache-dependency-path: 'vimhelp/requirements.txt'
- name: Set up vimhelp
run: |
pip install -r vimhelp/requirements.txt
- name: Build the documentation
run: |
echo "MacVim commit: ${MACVIM_COMMIT}"
echo "MacVim release: ${MACVIM_VERSION}"
echo "Vim version: ${VIM_VERSION}"
version_string="r${MACVIM_VERSION} (Vim ${VIM_VERSION})"
echo "Version string: $version_string"
cd vimhelp
python3 scripts/h2h.py -i "$MACVIM_DIR/runtime/doc" -o ../build --project macvim --web-version --output-tags-json --version "$version_string" --commit "$MACVIM_COMMIT"
- name: Generate sitemap
run: |
cd build
${GITHUB_WORKSPACE}/scripts/generate_sitemap > sitemap.txt
- name: Upload page artifact
uses: actions/upload-pages-artifact@v4
with:
path: build
# Deploy the artifact to the page
deploy:
needs: build
# Only allow deployment if on main branch (environmental protection would
# block it otherwise anyway), and if we haven't already built this version
# already.
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'workflow_dispatch' || needs.build.outputs.macvim_commit_cache_hit != 'true') }}
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Deployment is good. Finish caching the commit info so we won't run
# again until either this repo or MacVim got updated.
- name: Generate built commit version info marker
if: ${{ needs.build.outputs.macvim_commit_cache_hit != 'true' && github.event_name != 'workflow_dispatch' }}
run: |
# This file is just a marker. Save the current date in case we are curious later when the last version was built.
date > "${GITHUB_WORKSPACE}/macvim-built-commit.txt"
- name: Update cache with commit version info
id: save-cache-macvim-commit
uses: actions/cache/save@v5
if: ${{ needs.build.outputs.macvim_commit_cache_hit != 'true' && github.event_name != 'workflow_dispatch' }}
with:
path: ${{ github.workspace }}/macvim-built-commit.txt
key: macvim-built-commit-${{ needs.build.outputs.docs_commit }}-${{ needs.build.outputs.macvim_commit }}