Skip to content

Update submodule update workflow to use PAT_TOKEN and simplify git co… #19

Update submodule update workflow to use PAT_TOKEN and simplify git co…

Update submodule update workflow to use PAT_TOKEN and simplify git co… #19

name: Update Submodules
on:
push:
branches:
- main
jobs:
update-submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository with Submodules
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }} # Reference the PAT_TOKEN secret
- name: Configure Git User
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Update Submodules
run: |
git submodule init
git submodule update
git submodule foreach '
git fetch origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
git merge -X ours --no-edit origin/$BRANCH || {
git merge --abort
git reset --hard origin/$BRANCH
}
git add -A
'
- name: Commit and Push Updates
run: |
git add .
git diff --staged --quiet || git commit -m "Update submodule references [skip ci]"
git push
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} # Ensure the token is passed as an environment variable