-
Notifications
You must be signed in to change notification settings - Fork 344
77 lines (67 loc) · 2.92 KB
/
update_dependencies.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
name: Update Mathlib Dependencies
on:
schedule:
- cron: '0 * * * *' # This will run every hour
workflow_dispatch:
jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- name: Install elan
run: |
set -o pipefail
curl -sSfL "https://github.com/leanprover/elan/releases/download/v3.1.1/elan-x86_64-unknown-linux-gnu.tar.gz" | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}"
- name: Get sha of branch
id: sha
run: |
SHA="$(git rev-parse --verify origin/update-dependencies-bot-use-only)"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Get PR and labels
if: ${{ steps.sha.outputs.sha }}
id: PR # all the steps below are skipped if 'ready-to-merge' is in the list of labels found here
uses: 8BitJonny/[email protected]
# TODO: this may not work properly if the same commit is pushed to multiple branches:
# https://github.com/8BitJonny/gh-get-current-pr/issues/8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.sha.outputs.sha }}
# Only return if PR is still open
filterOutClosed: true
- name: Print PR, if found
run: echo "Found PR ${prNumber} at ${prUrl}"
if: steps.PR.outputs.pr_found == 'true'
env:
prNumber: ${{ steps.PR.outputs.number }}
prUrl: ${{ steps.PR.outputs.pr_url }}
- name: Configure Git User
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
run: |
git config user.name "leanprover-community-mathlib4-bot"
git config user.email "[email protected]"
- name: Update dependencies
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
run: lake update
- name: Generate PR title
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
run: |
echo "timestamp=$(date -u +"%Y-%m-%d-%H-%M")" >> "$GITHUB_ENV"
echo "pr_title=chore: update Mathlib dependencies $(date -u +"%Y-%m-%d")" >> "$GITHUB_ENV"
- name: Create Pull Request
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
uses: peter-evans/create-pull-request@v7
with:
token: "${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}"
commit-message: "chore: update Mathlib dependencies ${{ env.timestamp }}"
# this branch is referenced in update_dependencies_zulip.yml
branch: "update-dependencies-bot-use-only"
base: master
title: "${{ env.pr_title }}"
body: "This PR updates the Mathlib dependencies."
labels: "auto-merge-after-CI"