Skip to content

Commit

Permalink
Fix Bash scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Panquesito7 committed Sep 28, 2023
1 parent 50d4849 commit 8ec8c9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
15 changes: 7 additions & 8 deletions src/tools/fetch_labels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/tools/pr_number.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 8ec8c9d

Please sign in to comment.