51 lines
1.5 KiB
Text
51 lines
1.5 KiB
Text
# Use gh as a credential helper
|
|
exec gh auth setup-git
|
|
|
|
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
|
|
|
|
# Create a repository with a file so it has a default branch
|
|
exec gh repo create ${ORG}/${REPO} --add-readme --private
|
|
|
|
# Defer repo cleanup
|
|
defer gh repo delete --yes ${ORG}/${REPO}
|
|
|
|
# Create a project
|
|
env PROJECT_TITLE=${REPO}-project
|
|
exec gh project create --owner=${ORG} --title=${PROJECT_TITLE} --format='json' --jq='.number'
|
|
stdout2env PROJECT_NUMBER
|
|
|
|
defer gh project delete --owner=${ORG} ${PROJECT_NUMBER}
|
|
|
|
# Clone the repo
|
|
exec gh repo clone ${ORG}/${REPO}
|
|
|
|
# Prepare a branch to PR
|
|
cd ${REPO}
|
|
exec git checkout -b feature-branch
|
|
exec git commit --allow-empty -m 'Empty Commit'
|
|
exec git push -u origin feature-branch
|
|
|
|
# Create the PR
|
|
exec gh pr create --title 'Feature Title' --body 'Feature Body' --project ${PROJECT_TITLE}
|
|
stdout2env PR_URL
|
|
|
|
# Check that default pr view is working
|
|
exec gh pr view ${PR_URL}
|
|
|
|
# Check the pr was added to the project
|
|
exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title'
|
|
stdout ${PROJECT_TITLE}
|
|
|
|
# Remove the pr from the project
|
|
exec gh pr edit ${PR_URL} --remove-project ${PROJECT_TITLE}
|
|
|
|
# Check the pr was removed from the project
|
|
exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title'
|
|
! stdout ${PROJECT_TITLE}
|
|
|
|
# Re add the pr to the project
|
|
exec gh pr edit ${PR_URL} --add-project ${PROJECT_TITLE}
|
|
|
|
# Check the pr was added to the project
|
|
exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title'
|
|
stdout ${PROJECT_TITLE}
|