-
Notifications
You must be signed in to change notification settings - Fork 1.3k
111 lines (106 loc) · 4.24 KB
/
update-git-version-and-manual-pages.yml
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
name: Synchronize with new Git version (if any)
on:
workflow_dispatch:
inputs:
force-rebuild:
description: Force re-building all manual pages (e.g. after a script change)
type: boolean
default: false
schedule:
# check daily for updates
- cron: '37 17 * * *'
jobs:
update-git-version-and-manual-pages:
concurrency:
group: "pages"
cancel-in-progress: false
if: github.event.repository.fork == false || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write # to push changes (if any)
pages: write # to deploy to GitHub Pages
id-token: write # to verify that the deployment source is legit
issues: write # to open tickets upon broken links
environment:
name: github-pages
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions
script
- name: ruby setup
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: update recorded Git version
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# this seems to be needed to let `bundle exec` see `vendor/bundle/`
{ bundle check || bundle install --frozen; } &&
# update recorded Git version
bundle exec ruby script/update-git-version.rb
- name: commit changes (if any)
id: commit
run: |
# Exit early if there are no changes
git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules -- hugo.yml &&
exit 0
version="$(git diff hugo.yml | sed -n '/^+ *latest_version: /{s/.*: //;p;q}')"
echo "result=$version" >>$GITHUB_OUTPUT
git \
-c user.name=${{ github.actor }} \
-c user.email=${{ github.actor }}@noreply.github.com \
commit -m "Update git-version ($version)" \
-m 'Updated via the `update-git-version-and-manual-pages.yml` GitHub workflow.' \
-- hugo.yml
- name: prepare worktree
if: steps.commit.outputs.result != '' || inputs.force-rebuild == true
run: git sparse-checkout disable
- name: clone git.git
if: steps.commit.outputs.result != '' || inputs.force-rebuild == true
run: git clone --bare https://github.com/git/git '${{ runner.temp }}/git'
- name: update manual pages
if: steps.commit.outputs.result != '' || inputs.force-rebuild == true
run: |
if test true = '${{ inputs.force-rebuild }}'
then
export RERUN=true
fi
bundle exec ruby script/update-docs.rb '${{ runner.temp }}/git' en
- name: commit manual pages
id: manual-pages
if: steps.commit.outputs.result != '' || inputs.force-rebuild == true
run: |
git add -A external/docs &&
if test true = '${{ inputs.force-rebuild }}' && git diff-index --cached --quiet HEAD --
then
echo '::notice::A manual pages rebuild was requested but resulted in no changes' >&2
exit 0
fi &&
version='${{ steps.commit.outputs.result }}' &&
git \
-c user.name=${{ github.actor }} \
-c user.email=${{ github.actor }}@noreply.github.com \
commit -m "Update manual pages (${version:-manually forced rebuild})" \
-m 'Updated via the `update-git-version-and-manual-pages.yml` GitHub workflow.' &&
echo "result=modified" >>$GITHUB_OUTPUT
- name: verify that there are no uncommitted changes
run: |
git update-index --refresh &&
if test -n "$(git diff HEAD)$(git ls-files --exclude-standard --other)"
then
echo '::error::there are uncommitted changes!' >&2
git status >&2
exit 1
fi
- name: deploy to GitHub Pages
if: steps.commit.outputs.result != '' || steps.manual-pages.outputs.result != ''
id: deploy
uses: ./.github/actions/deploy-to-github-pages
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}