From 8ec8c9d816836d8c76297532ffc2f834e27e32f8 Mon Sep 17 00:00:00 2001 From: David Leal Date: Thu, 28 Sep 2023 19:11:33 +0000 Subject: [PATCH] Fix Bash scripts --- action.yml | 4 ++-- src/tools/fetch_labels.sh | 15 +++++++-------- src/tools/pr_number.sh | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index e050670..5cde903 100644 --- a/action.yml +++ b/action.yml @@ -121,7 +121,7 @@ runs: # Obtain the PR body and the necessary labels. PR_BODY=$(bash ${{ github.action_path }}/src/tools/markdown_pr_body.sh "added" "false" "${{ github.action_path }}") - LABELS_FETCH=$(bash ${{ github.action_path }}/src/tools/fetch_labels.sh "${{ github.action_path }}" "${{ env.REPOS_FILENAME }}" "fetch") + LABELS_FETCH=$(bash ${{ github.action_path }}/src/tools/fetch_labels.sh "${{ env.REPOS_FILENAME }}" "fetch") # Create the pull request with the given data. gh pr create --base ${GITHUB_REF##*/} --head ${{ inputs.branch_name }} --title '${{ inputs.commit_message }}' --body "Repositories were added or updated using the Submodules Alternative tool." || true @@ -136,7 +136,7 @@ runs: # Get the branches that will be used to create the PRs. BRANCHES=$(lua -e 'local repos = require("${{ env.REPOS_FILENAME }}").repos; dofile("${{ github.action_path }}/src/helper-functions.lua"); get_repo_branches(repos)') - LABELS_UPDATE=$(bash ${{ github.action_path }}/src/tools/fetch_labels.sh "${{ github.action_path }}" "${{ env.REPOS_FILENAME }}" "update") + LABELS_UPDATE=$(bash ${{ github.action_path }}/src/tools/fetch_labels.sh "${{ env.REPOS_FILENAME }}" "update") for branch in ${BRANCHES[@]}; do # Obtain the PR body and adjust it to the updated subtree. diff --git a/src/tools/fetch_labels.sh b/src/tools/fetch_labels.sh index b9c7700..6302a24 100644 --- a/src/tools/fetch_labels.sh +++ b/src/tools/fetch_labels.sh @@ -3,18 +3,17 @@ # # Arguments: # [0]: Taken by Bash, the name of the script -# [1]: The action path to obtain the necessary files. -# [2]: The repositories filename to obtain the configuration from. E.g.: `repos.lua` -# [3]: The mode that will be used. Available modes are: "fetch" and "update" +# [1]: The repositories filename to obtain the configuration from. E.g.: `repos.lua` +# [2]: The mode that will be used. Available modes are: "fetch" and "update" labels="" -if [ args[3] == "fetch" ]; then - labels=$(lua -e 'local labels = require("args[2]").config; if labels.labels_fetch then print(labels.labels_fetch) end') || "repo-fetch,dependencies" -elif [ args[3] == "update" ]; then - labels=$(lua -e 'local labels = require("args[2]").config; if labels.labels_update then print(labels.labels_update) end') || "dependencies" +if [ "$3" == "fetch" ]; then + labels=$(lua -e 'local labels = require("$2").config; if labels.labels_fetch then print(labels.labels_fetch) end') || "repo-fetch,dependencies" +elif [ "$3" == "update" ]; then + labels=$(lua -e 'local labels = require("$2").config; if labels.labels_update then print(labels.labels_update) end') || "dependencies" else - echo "Invalid mode. Providing basic labels" + # Invalid mode. Basic labels will be used instead. labels="dependencies" fi diff --git a/src/tools/pr_number.sh b/src/tools/pr_number.sh index 13686b7..75859f8 100755 --- a/src/tools/pr_number.sh +++ b/src/tools/pr_number.sh @@ -6,7 +6,7 @@ # [1]: The current branch name. Usually `${GITHUB_REF##*/}` # [2]: The branch name that has the new changes -pr=$(gh pr list --base args[1] --head args[2]) +pr=$(gh pr list --base $1 --head $2) pr_number=$(echo $pr | cut -d' ' -f1) # Does it have any content?