|
1 |
| -name: 'Update Carch Submodule' |
| 1 | +name: 'Update Carch-X Submodule' |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
| 5 | + branches: |
| 6 | + - 'main' # Trigger on push to the main branch |
5 | 7 | paths:
|
6 |
| - - 'carch-x/**' |
7 |
| - workflow_dispatch: |
| 8 | + - 'carch-x/**' # Detects changes in the carch-x submodule |
| 9 | + workflow_dispatch: # Allows manual triggering of the workflow |
8 | 10 |
|
9 | 11 | permissions:
|
10 |
| - contents: write |
11 |
| - actions: read |
| 12 | + contents: write # This grants read and write access to repository contents (pushes, commits, etc.) |
| 13 | + actions: read # This grants read access to actions (necessary for workflow) |
12 | 14 |
|
13 | 15 | jobs:
|
14 | 16 | update-submodule:
|
15 | 17 | runs-on: ubuntu-latest
|
16 | 18 |
|
17 | 19 | steps:
|
18 |
| - - name: Checkout documentation repository |
| 20 | + - name: Checkout carch repository |
19 | 21 | uses: actions/checkout@v3
|
20 | 22 | with:
|
21 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + token: ${{ secrets.GITHUB_TOKEN }} # Use the token with the specified permissions |
22 | 24 |
|
23 | 25 | - name: Set Git identity
|
24 | 26 | run: |
|
25 | 27 | git config --global user.name "GitHub Actions"
|
26 | 28 | git config --global user.email "[email protected]"
|
27 | 29 |
|
28 |
| - - name: Initialize and update submodules |
| 30 | + - name: Initialize and update carch-x submodule |
29 | 31 | run: |
|
30 | 32 | git submodule init
|
31 |
| - git submodule update |
| 33 | + git submodule update --remote carch-x # Pull the latest commit for the carch-x submodule |
32 | 34 |
|
33 |
| - - name: Pull latest changes for submodule |
| 35 | + - name: Check for changes in carch-x submodule |
34 | 36 | run: |
|
35 |
| - cd carch |
36 |
| - git fetch --all |
37 |
| - git checkout main |
38 |
| - git pull origin main |
| 37 | + if git diff --exit-code carch-x; then |
| 38 | + echo "No changes in carch-x submodule." |
| 39 | + else |
| 40 | + echo "carch-x submodule has changes" |
| 41 | + fi |
39 | 42 |
|
40 |
| - - name: Commit and push changes to the docs repository |
| 43 | + - name: Commit and push changes to the carch repository |
41 | 44 | run: |
|
42 |
| - git add carch |
43 |
| - git commit -m "Update carch submodule" |
44 |
| - git push origin main |
| 45 | + git add carch-x # Add changes from the carch-x submodule |
| 46 | + git commit -m "Update carch-x submodule" || echo "No changes to commit" |
| 47 | + git push origin main # Push the updates to the main branch |
| 48 | +
|
0 commit comments