Synchronize with new Git version (if any) #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |