forked from git/git-scm.com
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Update download data | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# check daily for updates | ||
- cron: '31 13 * * *' | ||
push: | ||
branches: | ||
- main | ||
- hugo | ||
|
||
permissions: | ||
contents: write # need to be able to push | ||
|
||
jobs: | ||
update-download-data: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: | | ||
_sync_state | ||
script | ||
- name: ruby setup | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: update download data | ||
id: update | ||
run: | | ||
# this seems to be needed to let `bundle exec` see `vendor/bundle/` | ||
{ bundle check || bundle install --frozen; } && | ||
# update download data | ||
bundle exec ruby ./update-download-data.rb && | ||
# commit changes (if any) | ||
if git diff-files --quiet --ignore-submodules -- | ||
then | ||
what="$(git diff hugo.yml | | ||
sed -n 's/^+ *filename: Git-\([.0-9]*\)-.*\.exe$/Git for Windows v\1/p')" | ||
mac="$(git diff hugo.yml | | ||
sed -n 's/^+ *filename: git-\([.0-9]*\)-.*\.dmg$/Git for macOS v\1/p')" | ||
test -z "$mac" || what="$what${what:+, }$mac" | ||
commit_message="Update download data ${what:+ ($what)}" | ||
echo "result=$commit_message" >>$GITHUB_OUTPUT | ||
git \ | ||
-c user.name=${{ github.actor }} \ | ||
-c user.email=${{ github.actor }}@noreply.github.com \ | ||
commit -m "$commit_message" && | ||
git bundle create download-data.bundle ${{ github.sha }}..${{ github.ref }} && | ||
git push origin HEAD | ||
- name: upload bundle | ||
if: steps.update.output.result != '' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bundle | ||
path: download-data.bundle | ||
outputs: | ||
commit-message: ${{ steps.update.outputs.result }} | ||
push-updates: | ||
needs: [update-download-data] | ||
if: needs.check-for-updates.outputs.matrix != '[""]' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/download-artifact@v3 | ||
- name: apply updates | ||
id: apply | ||
shell: bash | ||
run: | | ||
langs= | ||
for bundle in bundle-*/*.bundle | ||
do | ||
git -c core.editor=: \ | ||
-c user.name=${{ github.actor }} \ | ||
-c user.email=${{ github.actor }}@noreply.github.com \ | ||
pull --no-rebase $bundle ${{ github.ref }} || | ||
exit 1 | ||
done | ||
- name: update gh-pages | ||
uses: ./.github/actions/update-gh-pages | ||
with: | ||
commit-message: ${{ needs.update-download-data.outputs.commit-message }} |