diff --git a/README.md b/README.md index 8d0b777..425958c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ An easy-to-use Git (Sub)modules alternative to make the cloning process easier.\ - 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. - Easily take a look at the changes **directly in the PR** without extra effort. Git Submodules changes cannot be seen via the PR diff. +- The scripts support both Linux (preferred) and Windows, which means that you can easily run the scripts on your machine or [Gitpod](https://www.gitpod.io) without using GitHub Actions. ## Usage @@ -80,7 +81,7 @@ jobs: update-repos: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # This pulls changes before doing any changes - uses: Panquesito7/submodules-alternative@v1.6.1 diff --git a/action.yml b/action.yml index e961c7c..bfa68eb 100644 --- a/action.yml +++ b/action.yml @@ -81,11 +81,6 @@ runs: default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) wget https://raw.githubusercontent.com/${{ github.repository }}/${default_branch}/${{ inputs.repos_filename }}.lua - - if [[ $(git diff --name-only) ]]; then - git add ${{ inputs.repos_filename }}.lua - git commit -m 'Update repositories file' - fi fi - name: Setup Lua shell: bash @@ -115,13 +110,13 @@ runs: shell: bash run: | if [[ ${{ inputs.add_repos }} == true ]]; then - lua ${{ github.action_path }}/fetch-repos.lua ${{ inputs.repos_filename }} ${{ inputs.squash_commits }} '${{ inputs.commit_message }}' + lua ${{ github.action_path }}/src/fetch-repos.lua ${{ inputs.repos_filename }} ${{ inputs.squash_commits }} '${{ inputs.commit_message }}' fi - name: Run update-repos script shell: bash run: | if [[ ${{ inputs.update_repos }} == true ]]; then - lua ${{ github.action_path }}/update-repos.lua ${{ inputs.repos_filename }} ${{ inputs.squash_commits }} ${{ inputs.one_pr }} '${{ inputs.commit_message_update }}' + lua ${{ github.action_path }}/src/update-repos.lua ${{ inputs.repos_filename }} ${{ inputs.squash_commits }} ${{ inputs.one_pr }} '${{ inputs.commit_message_update }}' fi - name: Push changes and create PR shell: bash @@ -130,7 +125,7 @@ runs: if [[ ${{ inputs.one_pr }} == true ]]; then # One PR for everything: fetching and updating. git push origin ${{ inputs.branch_name }}:${{ inputs.branch_name }} || true - pr_body=$(bash ${{ github.action_path }}/tools/markdown_pr_body.sh "all" "false" "${{ github.action_path }}") + pr_body=$(bash ${{ github.action_path }}/src/tools/markdown_pr_body.sh "all" "false" "${{ github.action_path }}") gh pr create --base ${GITHUB_REF##*/} --head ${{ inputs.branch_name }} --title '${{ inputs.commit_message }}' --body "$pr_body" || true else # The One PR option is not available when adding the repositories. # The code below creates one PR for fetching all the subtrees. @@ -141,7 +136,7 @@ runs: pr=$(gh pr list --base ${GITHUB_REF##*/} --head $branch) pr_number=$(echo $pr | cut -d ' ' -f 1) - pr_body=$(bash ${{ github.action_path }}/tools/markdown_pr_body.sh "added" "false" "${{ github.action_path }}") + pr_body=$(bash ${{ github.action_path }}/src/tools/markdown_pr_body.sh "added" "false" "${{ github.action_path }}") labels_fetch=$(lua -e 'local labels = require("${{ inputs.repos_filename }}").config; if labels.labels_fetch then print(labels.labels_fetch) end') || "repo-fetch,dependencies" gh pr create --base ${GITHUB_REF##*/} --head ${{ inputs.branch_name }} --title '${{ inputs.commit_message }}' --body "$(lua -e 'local config = require("${{ inputs.repos_filename }}").config; if config.fetch then print(config.fetch) else print("Repositories were added or updated using the Submodules Alternative tool.") end')" || true @@ -151,12 +146,12 @@ runs: fi elif [[ ${{ inputs.update_repos }} == true ]] && [[ ${{ inputs.add_repos }} == false ]]; then # The One PR option is available when updating the repositories. - branches=$(lua -e 'local repos = require("${{ inputs.repos_filename }}").repos; dofile("${{ github.action_path }}/helper-functions.lua"); get_repo_branches(repos)') + branches=$(lua -e 'local repos = require("${{ inputs.repos_filename }}").repos; dofile("${{ github.action_path }}/src/helper-functions.lua"); get_repo_branches(repos)') labels_update=$(lua -e 'local labels = require("${{ inputs.repos_filename }}").config; if labels.labels_update then print(labels.labels_update) end') || "dependencies" for branch in ${branches[@]}; do repo_name=${branch%-update} - pr_body=$(bash ${{ github.action_path }}/tools/markdown_pr_body.sh "updated" "true" "${{ github.action_path }}" $repo_name) + pr_body=$(bash ${{ github.action_path }}/src/tools/markdown_pr_body.sh "updated" "true" "${{ github.action_path }}" $repo_name) gh pr create --base ${GITHUB_REF##*/} --head $branch --title 'Bump `'$repo_name'` to its latest commit' --body "$pr_body" || true diff --git a/fetch-repos.lua b/src/fetch-repos.lua similarity index 100% rename from fetch-repos.lua rename to src/fetch-repos.lua diff --git a/helper-functions.lua b/src/helper-functions.lua similarity index 100% rename from helper-functions.lua rename to src/helper-functions.lua diff --git a/tools/markdown_pr_body.sh b/src/tools/markdown_pr_body.sh similarity index 100% rename from tools/markdown_pr_body.sh rename to src/tools/markdown_pr_body.sh diff --git a/tools/pr_body.txt b/src/tools/pr_body.txt similarity index 100% rename from tools/pr_body.txt rename to src/tools/pr_body.txt diff --git a/tools/pr_body_fetch.txt b/src/tools/pr_body_fetch.txt similarity index 100% rename from tools/pr_body_fetch.txt rename to src/tools/pr_body_fetch.txt diff --git a/tools/pr_body_update.txt b/src/tools/pr_body_update.txt similarity index 100% rename from tools/pr_body_update.txt rename to src/tools/pr_body_update.txt diff --git a/tools/pr_body_update_separate.txt b/src/tools/pr_body_update_separate.txt similarity index 100% rename from tools/pr_body_update_separate.txt rename to src/tools/pr_body_update_separate.txt diff --git a/update-repos.lua b/src/update-repos.lua similarity index 100% rename from update-repos.lua rename to src/update-repos.lua