99 update-dependencies :
1010 runs-on : ubuntu-latest
1111 if : github.repository == 'leanprover-community/mathlib4'
12+ env :
13+ BRANCH_NAME : " update-dependencies-bot-use-only"
1214 steps :
1315 - name : Checkout repository
1416 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -23,13 +25,28 @@ jobs:
2325 use-github-cache : false
2426 use-mathlib-cache : false
2527
28+ - name : Get branch SHA if it exists
29+ id : get-branch-sha
30+ run : |
31+ # Check if the branch exists remotely
32+ if git fetch origin "$BRANCH_NAME"; then
33+ SHA=$(git rev-parse "origin/$BRANCH_NAME")
34+ echo "Branch '$BRANCH_NAME' exists with SHA: $SHA"
35+ echo "sha=$SHA" >> "${GITHUB_OUTPUT}"
36+ else
37+ echo "Branch '$BRANCH_NAME' does not exist"
38+ echo "sha=" >>" ${GITHUB_OUTPUT}"
39+ fi
40+
2641 - name : Get PR and labels
42+ if : ${{ steps.get-branch-sha.outputs.sha != '' }}
2743 id : PR # all the steps below are skipped if 'ready-to-merge' is in the list of labels found here
2844 uses : 8BitJonny/gh-get-current-pr@4056877062a1f3b624d5d4c2bedefa9cf51435c9 # 4.0.0
2945 # TODO: this may not work properly if the same commit is pushed to multiple branches:
3046 # https://github.com/8BitJonny/gh-get-current-pr/issues/8
3147 with :
3248 github-token : ${{ secrets.GITHUB_TOKEN }}
49+ sha : ${{ steps.get-branch-sha.outputs.sha }}
3350 # Only return if PR is still open
3451 filterOutClosed : true
3552
4057 prNumber : ${{ steps.PR.outputs.number }}
4158 prUrl : ${{ steps.PR.outputs.pr_url }}
4259
43- - name : Configure Git User
44- if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
45- run : |
46- git config user.name "leanprover-community-mathlib4-bot"
47- git config user.email "[email protected] " 48-
4960 - name : Update dependencies
5061 if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
5162 run : lake update -v
@@ -61,22 +72,44 @@ jobs:
6172 echo "toolchain_modified=false" >> "$GITHUB_OUTPUT"
6273 fi
6374
64- - name : Generate PR title
75+ - name : Check if lake-manifest.json was modified
6576 if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_toolchain.outputs.toolchain_modified != 'true' }}
77+ id : check_manifest
78+ run : |
79+ if [ -n "${{ steps.get-branch-sha.outputs.sha }}" ]; then
80+ # Branch exists, compare the file
81+ if git diff --quiet HEAD "origin/$BRANCH_NAME" -- lake-manifest.json; then
82+ echo "has_diff=false" >> "${GITHUB_OUTPUT}"
83+ echo "No differences in lake-manifest.json"
84+ else
85+ echo "has_diff=true" >> "${GITHUB_OUTPUT}"
86+ echo "Differences found in lake-manifest.json"
87+ fi
88+ else
89+ # Branch doesn't exist, consider it as different
90+ echo "has_diff=true" >> "${GITHUB_OUTPUT}"
91+ echo "Branch does not exist, treating as different"
92+ fi
93+
94+ - name : Generate PR title
95+ if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_manifest.outputs.has_diff == 'true' }}
6696 run : |
6797 echo "timestamp=$(date -u +"%Y-%m-%d-%H-%M")" >> "$GITHUB_ENV"
6898 echo "pr_title=chore: update Mathlib dependencies $(date -u +"%Y-%m-%d")" >> "$GITHUB_ENV"
6999
70100 - name : Create Pull Request
71- if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_toolchain .outputs.toolchain_modified ! = 'true' }}
101+ if : ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_manifest .outputs.has_diff = = 'true' }}
72102 uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
73103 with :
74104 token : " ${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}"
75105 author :
" leanprover-community-mathlib4-bot <[email protected] >" 76106 commit-message : " chore: update Mathlib dependencies ${{ env.timestamp }}"
77107 # this branch is referenced in update_dependencies_zulip.yml
78- branch : " update-dependencies-bot-use-only "
108+ branch : ${{ env.BRANCH_NAME }}
79109 base : master
80110 title : " ${{ env.pr_title }}"
81- body : " This PR updates the Mathlib dependencies."
111+ body : |
112+ This PR updates the Mathlib dependencies.
113+
114+ [workflow run for this PR](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
82115 labels : " auto-merge-after-CI"
0 commit comments