-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (62 loc) · 2.61 KB
/
sumbodule-update.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
name: Update Submodule
on:
schedule:
- cron: '0 * * * *' # Runs every hour
workflow_dispatch:
jobs:
update-submodule:
runs-on: ubuntu-latest
steps:
# Checkout the main repository and its submodules
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true # Initialize submodules
fetch-depth: 0 # Fetch full history to ensure we can compare commits
ref: dev # Checkout the 'dev' branch
# Ensure the submodule URL is correctly configured to use HTTPS
- name: Ensure correct submodule URL
run: |
echo "Ensuring submodule URL is set to HTTPS..."
git config --file .gitmodules submodule.wormhole-docs.url https://github.com/wormhole-foundation/wormhole-docs.git
echo "Submodule URL ensured."
# Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
# Install any dependencies (if necessary)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Configure Git user identity
- name: Configure Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
# Check for updates in the submodule and commit if there are changes
- name: Check for updates in submodule
run: |
echo "Checking for submodule updates..."
git submodule update --init --remote
cd wormhole-docs
git fetch origin
echo "Fetched latest changes from submodule remote."
# Ensure the branch 'main' exists in the submodule
if [ "$(git rev-list HEAD...origin/main --count)" -ne 0 ]; then
echo "Updates found. Pulling latest changes..."
git pull origin main || exit 1 # Stop if pull fails
cd ..
git add wormhole-docs
git commit -m "Update wormhole-docs submodule to latest commit" || echo "No changes to commit"
else
echo "No updates found in the submodule."
fi
# Push any changes to the dev branch
- name: Push changes to dev branch
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # Use PAT instead of default GITHUB_TOKEN
run: |
echo "Pushing changes to the dev branch..."
git push https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/kapetan3sid/wormhole-mkdocs.git dev || echo "No changes to push."