Skip to content

Commit 01e1661

Browse files
authored
Enhance workflow for generating VicUtils documentation
Updated the GitHub Actions workflow to include permissions and improved the commit logic for generated documentation.
1 parent 7566bf1 commit 01e1661

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

.github/workflows/generate-vicutils-docs.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ on:
77
branches:
88
- main
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
generate-docs:
1215
runs-on: ubuntu-latest
1316
steps:
14-
- uses: actions/checkout@v3
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
1521

16-
- uses: actions/setup-python@v4
22+
- name: Setup Python
23+
uses: actions/setup-python@v4
1724
with:
1825
python-version: '3.x'
1926

@@ -25,16 +32,26 @@ jobs:
2532
cd vicutils
2633
for file in *.py; do
2734
if [ "$file" != "__init__.py" ]; then
35+
echo "Generating docs for $file"
2836
pdoc --html --force --output-dir . "${file%.py}"
2937
# Move generated HTML to parent directory name
30-
mv "${file%.py}"/index.html "${file%.py}.html" 2>/dev/null || true
31-
rm -rf "${file%.py}"
38+
if [ -d "${file%.py}" ]; then
39+
mv "${file%.py}"/index.html "${file%.py}.html" 2>/dev/null || true
40+
rm -rf "${file%.py}"
41+
fi
3242
fi
3343
done
44+
cd ..
45+
ls -la vicutils/
3446
3547
- name: Commit and push if changes
3648
run: |
37-
git config user.name "Vic-Nas"
38-
git config user.email "github-actions@github.com"
49+
git config --local user.name "Vic-Nas"
50+
git config --local user.email "github-actions@github.com"
3951
git add vicutils/*.html
40-
git diff --quiet && git diff --staged --quiet || (git commit -m "Auto-generate VicUtils documentation" && git push)
52+
if git diff --staged --quiet; then
53+
echo "No changes to commit"
54+
else
55+
git commit -m "Auto-generate VicUtils documentation [skip ci]"
56+
git push
57+
fi

0 commit comments

Comments
 (0)