-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
133 lines (122 loc) · 4.57 KB
/
action.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: "Lean update"
description: "Attempts to update lean and dependencies of a lean project"
author: "Oliver Butterley"
inputs:
on_update_succeeds:
description: |
What to do when an update is available and the build is successful.
Allowed values: "silent", "commit", "issue" or "pr".
Default: "silent".
required: true
default: "silent"
on_update_fails:
description: |
What to do when an update is available and the build fails.
Allowed values: "silent", "issue" or "pr".
Default: "silent".
required: true
default: "silent"
token:
description: |
A Github token to be used for committing
required: true
default: ${{ github.token }}
outputs:
result:
description: "The action outputs `up-to-date`, `update-succeeds` or `update-fails` depending on the three possible scenarios."
value: ${{ steps.record-outcome.outputs.outcome }}
runs:
using: "composite"
steps:
- name: Update lean-toolchain
run: ${{ github.action_path }}/scripts/getLatest.ps1
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
- name: Install elan
run: |
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y
echo "$HOME/.elan/bin" >> $GITHUB_PATH
shell: bash
- name: Update dependencies of ${{ github.repository }}
run: lake -R -Kenv=dev update
shell: bash
- name: Check if lean-toolchain or lake-manifest.json were updated
id: check-update
run: |
OUTCOME=$(bash ${{ github.action_path }}/check-changes.sh)
echo "$OUTCOME" >> "$GITHUB_OUTPUT"
echo "info: $OUTCOME"
shell: bash
- name: Try to build lean if something was updated
if: steps.check-update.outputs.files_changed == 'true'
id: build-lean
continue-on-error: true
uses: leanprover/lean-action@v1
- name: Record outcome
id: record-outcome
run: |
if "${{steps.check-update.outputs.files_changed == 'false'}}" ; then
echo "No update available"
echo "outcome=no-update" >> "$GITHUB_OUTPUT"
elif "${{steps.build-lean.outcome == 'success'}}"; then
echo "Update available and build successful"
echo "outcome=update-success" >> "$GITHUB_OUTPUT";
elif "${{steps.build-lean.outcome == 'failure'}}"; then
echo "Update available but build fails"
echo "outcome=update-fail" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Open PR if the updated lean build was successful
if: steps.build-lean.outcome == 'success' && inputs.on_update_succeeds == 'pr'
uses: peter-evans/create-pull-request@v7
with:
title: "Updates available and ready to merge"
body: "To do: add useful details here..."
delete-branch: true
branch-suffix: random
branch: auto-update/patch
labels: "auto-update-lean"
- name: Open issue if the updated lean build was successful
if: steps.build-lean.outcome == 'success' && inputs.on_update_succeeds == 'issue'
run: |
gh issue create \
--title "$TITLE" \
--label "$LABELS" \
--body "$BODY"
env:
# Could be best to use the default token here
GH_TOKEN: ${{ inputs.token }}
GH_REPO: ${{ github.repository }}
TITLE: Updates available and have been tested to build correctly
BODY: |
Some more useful info could be added here...
shell: bash
- name: Commit update if the updated lean build was successful
if: steps.build-lean.outcome == 'success' && inputs.on_update_succeeds == 'commit'
uses: EndBug/[email protected]
with:
default_author: github_actions
- name: Open issue if the updated lean build fails
if: steps.build-lean.outcome == 'failure' && inputs.on_update_fails == 'issue'
run: |
gh issue create \
--title "$TITLE" \
--label "$LABELS" \
--body "$BODY"
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: ${{ github.repository }}
TITLE: Updates available but manual intervention required
# LABELS: bug
BODY: |
Try `lake update` and then investigate why this update causes the lean build to fail.
Files changed in update: ${{ steps.check-update.outputs.changed_files }}
shell: bash
- name: Action fails if the updated lean build fails
if: steps.build-lean.outcome == 'failure' && inputs.on_update_fails == 'fail'
run: exit 1
shell: bash
branding:
icon: "download-cloud"
color: "blue"