-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (80 loc) · 3.85 KB
/
update-checks-list.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
name: update-checks-list
# Run manually or when dispatched by a new threedi-modelchecker release.
on:
workflow_dispatch:
inputs:
reviewer_name:
description: "Who to ask for a review (github username)"
default: "elisalle"
required: true
jobs:
update_checks_list:
runs-on: ubuntu-22.04
outputs:
checks_changed: ${{ steps.check_files.outputs.checks_changed }}
checker_version: ${{ steps.fetch_version.outputs.checker_version }}
steps:
# Checkout the code.
- uses: actions/checkout@v4
- name: set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: install threedi-modelchecker
run: python -m pip install threedi-modelchecker
- name: generate and overwrite schematisation checks list
run: threedi_modelchecker export-checks --format rst --file source/i_current_schematisation_checks_table.rst
- name: fetch threedi-modelchecker version name
id: fetch_version
run: echo "checker_version=$(python -c 'import threedi_modelchecker; print(threedi_modelchecker.__version__)')" >> "$GITHUB_OUTPUT"
- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD
echo "========== check paths of modified files =========="
files_changed=$(git diff --name-only HEAD | tr -d '\n')
if [[ $files_changed == source/i_current_schematisation_checks_table.rst ]]; then
echo "Schematisation checks table has changed"
echo "checks_changed=true" >> "$GITHUB_OUTPUT"
else
echo "Schematisation checks table has not changed"
echo "checks_changed=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/upload-artifact@v3
with:
path: source/i_current_schematisation_checks_table.rst
create_pr:
runs-on: ubuntu-22.04
needs: update_checks_list
if: needs.update_checks_list.outputs.checks_changed == 'true' # don't run if the checks table hasn't changed
steps:
# Checkout the code.
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: move downloaded artifact file to correct place
run: |
mv artifact/i_current_schematisation_checks_table.rst source
rm -rf artifact
- name: set environment variables
run: |
echo "PR_TITLE=Update schematisation checks for threedi-modelchecker ${{ needs.update_checks_list.outputs.checker_version }}" >> "$GITHUB_ENV"
echo "PR_BODY=This PR was auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).\
It is usually triggered by a new threedi-modelchecker release, but can also be run by hand. This PR updates the documented\
list of checks run by the modelchecker to reflect the latest threedi-modelchecker version,\
${{ needs.update_checks_list.outputs.checker_version }}. **Please note:** The `build_and_deploy`\
workflow cannot be triggered by this bot, so to run the required checks, please close and reopen\
this pull request." >> $GITHUB_ENV
- name: create pull request
uses: peter-evans/create-pull-request@v5
with:
title: ${{ env.PR_TITLE }}
commit-message: ${{ env.PR_TITLE }}
committer: GitHub <[email protected]>
author: github-actions <[email protected]>
body: ${{ env.PR_BODY }}
branch: update-schematisation-checks-${{ needs.update_checks_list.outputs.checker_version }}
add-paths: |
source/i_current_schematisation_checks_table.rst
assignees: ${{ github.event.inputs.reviewer_name }}
reviewers: ${{ github.event.inputs.reviewer_name }}