-
Notifications
You must be signed in to change notification settings - Fork 26
77 lines (63 loc) · 2.26 KB
/
document-scripts.yml
File metadata and controls
77 lines (63 loc) · 2.26 KB
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
# This workflow will automatically update the README for any updated MLC script
name: Document script on modified meta
on:
push:
branches: [ "dev" ]
paths:
- 'script/**meta.yaml'
jobs:
get_modified_files:
runs-on: ubuntu-latest
if: github.repository_owner == 'mlcommons'
outputs:
processed_files: ${{ steps.modified-files.outputs.processed_files }}
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install pyyaml
- name: Get changed files
id: modified-files
env:
filter: ${{ github.event.before }}
run: |
changed_files=$(git diff --name-only $filter | grep -E '.*\.yaml$' | paste -sd, -)
echo "$changed_files" | python3 .github/scripts/list_modified_files.py
document_modified_scripts:
runs-on: ubuntu-latest
needs: get_modified_files
if: ${{ needs.get_modified_files.outputs.processed_files != '[]' && needs.get_modified_files.outputs.processed_files != '' }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
modified_metas: ${{ fromJSON(needs.get_modified_files.outputs.processed_files).modified_metas }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: automation-scripts
- name: Document meta.yaml file
run: |
echo "Documenting ${{ matrix.modified_metas.file }}"
python3 -m venv mlcflow
. mlcflow/bin/activate
pip install mlcflow
mlc add repo automation-scripts
mlc doc script ${{ matrix.modified_metas.uid}} --quiet
cd automation-scripts
find . -type f -name README.md -exec git add {} +
# Use the GitHub actor's name and email
git config user.name github-actions[bot]
git config user.email "github-actions[bot]@users.noreply.github.com"
# Commit changes
git diff-index --quiet HEAD || (git commit -am "[Automated Commit] Document ${{ matrix.modified_metas.file}} [skip ci]" && git push)