Skip to content

Commit 614e7f9

Browse files
committed
Update the download data via a GitHub workflow
This workflow has a `workflow_dispatch` trigger to allow for manually starting this workflow directly after, say, a Git for Windows version was released. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8378b88 commit 614e7f9

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update download data
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# check daily for updates
7+
- cron: '31 13 * * *'
8+
9+
jobs:
10+
update-download-data:
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 download data
30+
run: |
31+
# this seems to be needed to let `bundle exec` see `vendor/bundle/`
32+
{ bundle check || bundle install --frozen; } &&
33+
34+
# update download data
35+
bundle exec ruby script/update-download-data.rb
36+
- name: commit changes (if any)
37+
id: commit
38+
run: |
39+
# Exit early if there are no changes
40+
git update-index --ignore-submodules --refresh &&
41+
git diff-files --quiet --ignore-submodules -- hugo.yml &&
42+
exit 0
43+
44+
what="$(git diff hugo.yml |
45+
sed -n '/^+ *filename: Git-\([.0-9]*\)-.*\.exe$/{s/.* Git-\([.0-9]*\)-.*/Git for Windows v\1/p;q}')"
46+
mac="$(git diff hugo.yml |
47+
sed -n 's/^+ *filename: git-\([.0-9]*\)-.*\.dmg$/Git for macOS v\1/p')"
48+
test -z "$mac" || what="$what${what:+, }$mac"
49+
commit_message="Update download data${what:+ ($what)}"
50+
echo "result=$commit_message" >>$GITHUB_OUTPUT
51+
52+
git \
53+
-c user.name=${{ github.actor }} \
54+
-c user.email=${{ github.actor }}@noreply.github.com \
55+
commit -m "$commit_message" \
56+
-m 'Updated via the `update-download-data.yml` GitHub workflow.' \
57+
-- hugo.yml
58+
- name: verify that there are no uncommitted changes
59+
run: |
60+
git update-index --refresh &&
61+
if test -n "$(git diff HEAD)$(git ls-files --exclude-standard --other)"
62+
then
63+
echo '::error::there are uncommitted changes!' >&2
64+
git status >&2
65+
exit 1
66+
fi
67+
- name: deploy to GitHub Pages
68+
if: steps.commit.outputs.result != ''
69+
id: deploy
70+
uses: ./.github/actions/deploy-to-github-pages

0 commit comments

Comments
 (0)