Skip to content

Commit 388a8d8

Browse files
authored
Add GitHub action for syncing submodules for readthedocs (#88)
This change adds a workflow that will automatically update the submodules and push their changes to this repo, so that readthedocs will be building with the latest docs from slang, slangpy, and the stdlib-reference.
1 parent da3ac4b commit 388a8d8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Update Submodules
2+
3+
on:
4+
schedule:
5+
# Run at 2:00 AM UTC every day
6+
- cron: '0 2 * * *'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
update-submodules:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
with:
18+
# Fetch all history for all branches and tags
19+
fetch-depth: 0
20+
# Get submodules
21+
submodules: 'recursive'
22+
23+
- name: Set up Git
24+
run: |
25+
git config --global user.name 'github-actions'
26+
git config --global user.email '[email protected]'
27+
28+
- name: Get default branch
29+
id: default_branch
30+
run: |
31+
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
32+
echo "name=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT
33+
34+
- name: Checkout default branch
35+
run: |
36+
git checkout ${{ steps.default_branch.outputs.name }}
37+
38+
- name: Update submodules
39+
run: |
40+
git submodule update --remote --recursive
41+
42+
- name: Check if submodules changed
43+
id: check_changes
44+
run: |
45+
if [[ -n "$(git status --porcelain)" ]]; then
46+
echo "changes=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "changes=false" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Commit and push changes
52+
if: steps.check_changes.outputs.changes == 'true'
53+
run: |
54+
git add -A
55+
git commit -m "Auto-update submodules"
56+
git push origin ${{ steps.default_branch.outputs.name }}

0 commit comments

Comments
 (0)