An easy-to-use Git modules alternative to make the cloning process easier.
LGPL-2.1 License
An easy-to-use Git (Sub)modules alternative to make the cloning process easier. The project is still WIP and still contains minor bugs. It is recommended to use it in small projects until the tool is fairly stable.
clone recursive
or submodule update
commands!repos.lua
(or as you desire) with all your selected repositories (template file). You can place it in any directory, just make sure to specify the directory in your workflow (see the next step).Your repos.lua
file should look similar to the following.
local config = {
labels_fetch = "repo-fetch,dependencies"
labels_update = "dependencies",
}
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/"
},
{
name = "panqkart",
url = "https://github.com/panqkart/panqkart",
dir = "games/"
}
}
-- Fully needed, so that the scripts can access the configurations.
return {
repos = repos,
config = config
}
This GitHub Action workflow will automatically update or clone the desired repositories. You can choose to update, clone, or do both actions. You can also configure how the script works.
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
workflow_dispatch: # This allows you to manually run the workflow whenever you want.
jobs:
update-repos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # This pulls changes before doing any changes
- uses: Panquesito7/[email protected]
with:
repos_filename: repos.lua # Both `repos.lua` and `repos` will work.
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. Cannot be used if `one_pr` is disabled.
one_pr: false # Creates one single PR for everything if enabled. Works only for `update_repos` if disabled.
Always use single-quoting for commit messages if you want to include special symbols such as !
.
After a PR is merged, its branch won't be automatically deleted, thus, the script will fail if there's a new update when the outdated branch still exists. If you want your branches to automatically delete after being merged, you should consider one of the following options:
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.
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. Git Software is also required to run a few commands.
Download Lua: https://www.lua.org/download.html Download Git Software: https://git-scm.com/downloads
Both
fetch-repos.lua
andupdate-repos.lua
requirehelper-functions.lua
for extra functions and safety checks.
lua fetch-repos.lua <repos_filename> <squash_commits> <commit_message>
git push
Please note that commit messages should include quoting (''
or ""
), else, the script will detect it as multiple parameters.
If you've updated your subtrees list, you can always run the script again and it'll clone the new subtrees.
By using GitHub Actions, the subtrees will be updated automatically. If you wish to do that manually, you can run the following script.
Remember to use (single-)quoting around the commit message!
lua update-repos.lua <repos_filename> <commit_message> <squash_commits>
After running the script, you can push changes to the desired branch. The script already takes care of committing everything.
All the pending work and to-do list can be found here: https://github.com/users/Panquesito7/projects/3
See LICENSE.md
for full information.