File bin/modules/github.sh

Last commit: Wed Dec 25 14:01:17 2024 +0100	Jan Dankert	Fix: Post correct JSON to Github API ;)
1 #!/bin/bash 2 3 echo "Pushing git repo to GitHub" 4 5 curl --fail --silent https://github.com/${github_owner}/${REPO_NAME} > /dev/null 6 7 # Checking if repo exists on github. 8 if [ $? -ne 0 ]; then 9 echo "Warning: GitHub-Project ${REPO_NAME} does not exist" 10 if [ -n "$github_access_token" ]; then 11 echo "GitHub-Repo will be created..." 12 curl -H "Authorization: token $github_access_token" \ 13 -d "{ \"name\": \"${REPO_NAME}\", 14 \"auto_init\": false, 15 \"private\": false, 16 \"has_issues\": false, 17 \"has_wiki\": false, 18 \"has_downloads\": false 19 }" https://api.github.com/user/repos 20 else 21 echo "Warning: No Github-token configured, so it is not possible to create a new repository at Github." 22 echo " Go to https://github.com/new to create the repo '$REPO_NAME'." 23 return # no project on github, exiting without error 24 fi 25 fi 26 27 28 if [ -n "$github_access_token" ]; then 29 echo "Updating repository description at Github ..." 30 curl -H "Authorization: token $github_access_token" \ 31 -d "{ \"description\": \"${repo_project_description}\" 32 }" https://api.github.com/repos/${github_owner}/${REPO_NAME} 33 fi 34 35 ssh -q git@github.com 36 37 if [ $? -ne 1 ]; then 38 echo "Warning: SSH Connection to GitHub failed with RC $?" 39 echo " Maybe there is no SSH Key for Github" 40 return 4 41 fi 42 43 # Push to remote repos 44 git push -vv --all git@github.com:${github_owner}/${REPO_NAME} 45 if [ $? -ne 0 ]; then 46 echo "Error: Push to github failed due to exitcode $?" 47 return 4 48 fi 49 50 git push -vv --tags git@github.com:${github_owner}/${REPO_NAME} 51 if [ $? -ne 0 ]; then 52 echo "Error: Push to github failed due to exitcode $?" 53 return 4 54 fi 55 56 return 0
Download bin/modules/github.sh
History Wed, 25 Dec 2024 14:01:17 +0100 Jan Dankert Fix: Post correct JSON to Github API ;) Wed, 25 Dec 2024 13:55:48 +0100 Jan Dankert The Github module is now able to create the project at Github. Wed, 27 Nov 2024 01:04:22 +0100 Jan Dankert Small fixes... Tue, 26 Nov 2024 23:26:36 +0100 Jan Dankert New: Creating a project website Sun, 12 May 2024 19:53:02 +0200 Jan Dankert first edition of DIT, the delivery expert.