GitHub Action
Submodules Alternative
An easy-to-use Git (Sub)modules alternative to make the cloning process easier.
- Cloning repositories is now super easier: anyone can clone your repository without the need for Git. No more
clone recursive
orsubmodule update
commands! - Submodule addition/update is automated by GitHub Actions (if desired), making it easier to integrate into your projects.
- Lightweight and documented codebase in Lua v5.3.3.
- Git Submodules can sometimes be messy or confusing, which this tool aims to solve.
- Lets you choose the desired branch of the repository, unlike Git Submodules which automatically chooses the default branch.
- Create a new file named
repos.lua
(or as you desire) with all your selected repositories (template file).
Your repos.lua
file should look similar to the following.
It is recommended to not include .git
at the end of URLs for various settings on the script.
local repos = {
{
name = "opencv",
url = "https://github.com/opencv/opencv",
dir = "libs/",
def_branch = "master"
},
{
name = "texto",
url = "https://github.com/realstealthninja/texto",
dir = "libs/"
},
}
-- Fully needed, so that the scripts can access the repositories.
return {
repos = repos
}
This GitHub Action workflow will automatically update or clone the desired repositories.
You can choose to update, clone, or do both actions.
name: Submodules Alternative
on:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 0 * * 1' # This would run weekly on Monday at 00:00 UTC
jobs:
update-repos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # This pulls changes before doing any changes
- uses: Panquesito7/[email protected]
with:
repos_filename: repos # In case your file is named `repos.lua`, you can leave it as `repos`.
use_pr: true # Whether to create a pull request when updating/adding the repositories.
branch_name: repo-update # The branch name to use (only if `use_pr` is enabled).
commit_message: "Update" # Commit message used when adding new repositories.
commit_message_update: "Bump repositories" # Commit message used when updating all the repositories.
add_repos: false # If enabled, this will clone all the repositories listed in your repos file.
update_repos: true # When enabled, this will attempt to update all the repositories.
squash_commits: false # Whether to squash all commits or not on every repository update/addition.
one_pr: false # Creates one single PR for everything if enabled. Works only for `update_repos` if disabled.
You can also configure to run the workflow manually by using workflow_dispatch
instead of schedule
.
For more information about Cron, you can check CronHub.
- Run
fetch-repos.lua
to clone all the repositories automatically.
Note
You will need to install Lua v5.3.3 in your
machine in case you do not have it installed.Download: https://www.lua.org/download.html
Both
fetch-repos.lua
andupdate-repos.lua
require
helper-functions.lua
for extra functions and safety checks.
lua fetch-repos.lua <repos_filename> <squash_commits> # No filename format required!
- Once done, you can push changes. Committing is already done by the script.
git push
- Done! All of your repositories are now available in your project and can be updated later on. 🎉
If you've updated your repositories list, you can always run the script again and it'll clone the new repositories.
By using GitHub Actions, the repositories will be updated automatically.
If you wish to do that manually, you can run the following script.
Remember to use ""
around the commit message!
lua update-repos.lua <repos_filename> <commit_message> <squash_commits> # No filename format required!
After running the script, you can push changes to the desired branch.
The script already takes care of committing everything.
- If the squash commits option is enabled, a new repository is added, and the workflow is run again, the commits should be squashed using
force-with-lease
. - Make sure all the options and everything work perfectly fine.
- Clean up the action code to work faster and better.
- Create a PR per repository update, just like Dependabot does.
See LICENSE
for full information.