generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_repo.sh
executable file
·42 lines (33 loc) · 1.05 KB
/
update_repo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
# Check if the commit message file argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <commit_message_file_path>"
exit 1
fi
COMMIT_MSG_FILE="$1"
if [ -f "$COMMIT_MSG_FILE" ]; then
echo "Changes detected. Proceeding with git operations."
# Read the first line as the PR title
PR_TITLE=$(head -n 1 "$COMMIT_MSG_FILE")
echo "PR Title: $PR_TITLE"
# Read the remaining lines as the PR body
PR_BODY=$(tail -n +2 "$COMMIT_MSG_FILE")
echo "PR Body: $PR_BODY"
echo "Pushing changes..."
git add .
git checkout -b update_fdroid_apps
git commit -F "$COMMIT_MSG_FILE"
git push -f -u origin update_fdroid_apps
echo "Creating PR..."
PR_URL=$(gh pr create --title "$PR_TITLE" \
--base main \
--label "automated pr" \
--body "$PR_BODY")
echo "pr_number=${PR_URL##*/}"
# Clean up the temporary commit message file
rm "$COMMIT_MSG_FILE"
else
echo "Error: Commit message file does not exist or could not be found: $COMMIT_MSG_FILE" >&2
exit 1
fi