GitHub Action: Creates a Commit when Submodule is Updated (Based on an this action)
Beware: this will update ALL submodules in the parent repository. I haven't had the motivation to figure out a way to only update the origin repository, due to that not being necessary for my workflow. I am accepting PR's tho.
This GitHub action creates a new commit against the parent repository when the submodule is updated.
The end goal of this tool: Automatically update the submodule in the parent repository.
To use this GitHub Action you will need to complete the following in the submodule repository:
- Parent repository has
.gitmodules
configured - Store GitHub token into secrets with permissions to write to parent repository
- Create a new file in your repository called
.github/workflows/submodule-update.yml
- Copy the example workflow from below into that new file and modify as needed
- Commit that file to a new branch
- Observe the action working
This file should have the following code:
---
name: Submodule Updates
on:
push
jobs:
build:
name: Submodule update
runs-on: ubuntu-latest
steps:
- name: run action
id: run_action
uses: PaulRitter/github-action-create-commit-parent-submodule@v1
with:
github_token: ${{ secrets.GH_ACTIONS_TOKEN }}
parent_repository: org/example-repository
parent_branch: main