Skip to content

Commit 9d9fe75

Browse files
committed
Add a workflow to update the Git version and manual pages
Whenever a new Git version is released, we will want git-scm.com to be updated automatically. To this end, add a scheduled workflow that does precisely that. In case someone gets too impatient to wait for the daily check, there's also a `workflow_dispatch` trigger. Note: It would be tempting to use a partial clone of git.git for this, but that would cause many, many round-trips (each time a blob is requested), especially when force-rebuilding all versions of all manual pages (which will be added in a later commit). So let's not. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d8dfcec commit 9d9fe75

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Synchronize with new Git version (if any)
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# check daily for updates
7+
- cron: '37 17 * * *'
8+
9+
jobs:
10+
update-git-version-and-manual-pages:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # to push changes (if any)
14+
pages: write # to deploy to GitHub Pages
15+
id-token: write # to verify that the deployment source is legit
16+
environment:
17+
name: github-pages
18+
url: ${{ steps.deploy.outputs.url }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
sparse-checkout: |
23+
.github/actions
24+
script
25+
- name: ruby setup
26+
uses: ruby/setup-ruby@v1
27+
with:
28+
bundler-cache: true
29+
- name: update recorded Git version
30+
env:
31+
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
# this seems to be needed to let `bundle exec` see `vendor/bundle/`
34+
{ bundle check || bundle install --frozen; } &&
35+
36+
# update recorded Git version
37+
bundle exec ruby script/update-git-version.rb
38+
- name: commit changes (if any)
39+
id: commit
40+
run: |
41+
# Exit early if there are no changes
42+
git update-index --ignore-submodules --refresh &&
43+
git diff-files --quiet --ignore-submodules -- hugo.yml &&
44+
exit 0
45+
46+
version="$(git diff hugo.yml | sed -n '/^+ *latest_version: /{s/.*: //;p;q}')"
47+
echo "result=$version" >>$GITHUB_OUTPUT
48+
49+
git \
50+
-c user.name=${{ github.actor }} \
51+
-c user.email=${{ github.actor }}@noreply.github.com \
52+
commit -m "Update git-version ($version)" \
53+
-m 'Updated via the `update-git-version-and-manual-pages.yml` GitHub workflow.' \
54+
-- hugo.yml
55+
- name: prepare worktree
56+
if: steps.commit.outputs.result != ''
57+
run: git sparse-checkout disable
58+
- name: clone git.git
59+
if: steps.commit.outputs.result != ''
60+
run: git clone --bare https://github.com/git/git '${{ runner.temp }}/git'
61+
- name: update manual pages
62+
if: steps.commit.outputs.result != ''
63+
run: bundle exec ruby script/update-docs.rb '${{ runner.temp }}/git' en
64+
- name: commit manual pages
65+
if: steps.commit.outputs.result != ''
66+
run: |
67+
git add -A external/docs &&
68+
git \
69+
-c user.name=${{ github.actor }} \
70+
-c user.email=${{ github.actor }}@noreply.github.com \
71+
commit -m "Update manual pages (${{ steps.commit.outputs.result }})" \
72+
-m 'Updated via the `update-git-version-and-manual-pages.yml` GitHub workflow.'
73+
- name: verify that there are no uncommitted changes
74+
run: |
75+
git update-index --refresh &&
76+
if test -n "$(git diff HEAD)$(git ls-files --exclude-standard --other)"
77+
then
78+
echo '::error::there are uncommitted changes!' >&2
79+
git status >&2
80+
exit 1
81+
fi
82+
- name: deploy to GitHub Pages
83+
if: steps.commit.outputs.result != ''
84+
id: deploy
85+
uses: ./.github/actions/deploy-to-github-pages

0 commit comments

Comments
 (0)