forked from rajbos/github-fork-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Leonard Sheng Sheng Lee edited this page Aug 15, 2024
·
1 revision
Welcome to the rajbos-github-fork-updater wiki!
#!/usr/bin/env bash
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
set -o pipefail # If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.
set -o errexit # set -e # Exit immediately if a pipeline, which may consist of a single simple command, a list, or a compound command returns a non-zero status.
set -o nounset # set -u # Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’, or array variables subscripted with ‘@’ or ‘*’, as an error when performing parameter expansion. An error message will be written to the standard error, and a non-interactive shell will exit.
# set -o xtrace # set -x # Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.
# https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
shopt -s inherit_errexit # If set, command substitution inherits the value of the errexit option, instead of unsetting it in the subshell environment. This option is enabled when POSIX mode is enabled.
if [ -d ".git" ] || git rev-parse --git-dir > /dev/null 2>&1; then
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
echo "\${GIT_ROOT_DIRECTORY}: ${GIT_ROOT_DIRECTORY}"
fi
SCRIPT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "\${SCRIPT_DIRECTORY}: ${SCRIPT_DIRECTORY}"
gh repo set-default https://github.com/sheeeng/rajbos-github-fork-updater
# Loop all opened issues and set issue label to "update-fork".
gh issue list --limit 200 --state=open --label "update-available" --json number,title,url | jq -r '.[] | "\(.number) \(.title) \(.url)"' | while read -r issue; do
issue_number=$(echo "${issue}" | cut -d' ' -f1)
issue_title=$(echo "${issue}" | cut -d' ' -f2-)
issue_url=$(echo "${issue}" | cut -d' ' -f3-)
echo "issue_number: ${issue_number}"
echo "issue_title: ${issue_title}"
echo "issue_url: ${issue_url}"
gh issue edit "${issue_number}" --add-label "update-fork"
done