Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanharikr committed Oct 23, 2023
1 parent 3b48772 commit e933f4f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 57 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"preview": "vite preview --open",
"test": "linkinator ./S3 --config linkinator.config.json",
"test:blog": "linkinator https://blog.hello.coop https://blog.hello.dev --config linkinator.config.json",
"review": "./scripts/review.mjs"
"pr": "./scripts/pr.sh",
"rebase": "git pull origin main --rebase",
"review": "npm run rebase && npm run test && npm run pr"
},
"engines": {
"node": "~18",
Expand Down
34 changes: 34 additions & 0 deletions scripts/pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Function to check for errors
check_error() {
if [ -n "$1" ]; then
echo "Error: $1"
afplay /System/Library/Sounds/Funk.aiff
exit 1
fi
}

# Check if not in the main branch
prBranchName=$(git branch --show-current)
if [ "$prBranchName" = "main" ]; then
check_error "Cannot start a review from main branch. Please switch to your development branch and try again."
fi

# Create PR
gh pr create --base main --title "$prBranchName" --body "" 2>&1
pr_create_status=$?
if [ $pr_create_status -ne 0 ]; then
if [ "$(grep -q 'already exists' <<< "$pr_create_status"; echo $?)" -ne 0 ]; then
check_error "Error creating PR"
fi
fi

# Play success sound (Only works on MacOS)
afplay /System/Library/Sounds/Glass.aiff

# GitHub-Slack app sends a PR created Slack message to #content-updates channel
check_error

# Exit with success
exit 0
14 changes: 0 additions & 14 deletions scripts/pre-requisites.mjs

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/pre-requisites.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

requiredPackages=("gh" "git")

for pkg in "${requiredPackages[@]}"; do
if ! which "$pkg" &>/dev/null; then
echo "$pkg is not installed"
exit 1
fi
done
42 changes: 0 additions & 42 deletions scripts/review.mjs

This file was deleted.

0 comments on commit e933f4f

Please sign in to comment.