commit 5415d10f56b52eac92b11bc96b345c32c78b2ba3 Author: Anish Lakhwara Date: Tue May 23 15:25:18 2023 +1000 Initial Commit diff --git a/.env b/.env new file mode 100644 index 0000000..421df68 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +export GITEA_TOKEN=f32cb554ac3aed90754d62d476043cebcfad272f diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..3f876fd --- /dev/null +++ b/README.rst @@ -0,0 +1,25 @@ + ___ __ ____ ____ __ ____ ____ ____ __ ___ ____ ____ __ ____ __ ____ + / __)( )(_ _)( __) / _\ ( _ \( __)( _ \ / \ / __)( _ \( __) / _\(_ _)/ \( _ \ +( (_ \ )( )( ) _) / \ ) / ) _) ) __/( O ) ( (__ ) / ) _) / \ )( ( O )) / + \___/(__) (__) (____)\_/\_/ (__\_)(____)(__) \__/ \___)(__\_)(____)\_/\_/(__) \__/(__\_) + +=============================================================================================== + +A simple bash command to create a gitea repository. + +Requirements +------------ + +* bash +* curl +* gitea user account and token + +Instructions +------------ + +First you must create a token that the application can use. This can be created on your user settings page in Gitea. (Maybe I'll write another script here that can create one for you from you password?) + +Once the token has been created, copy the `env.sample` file to `.env` and place your token into the exported environment variable. +Now you can create a symbolic link to the create script to some folder that is included in your `PATH` (either `/usr/local/bin` or `~/.local/bin` are generally supported, but it depends on the distribution) + +This script also initializes the git repo, adds everything currently in your directory and commits it to git. This can be changed via `CREATE_REPO` diff --git a/create.sh b/create.sh new file mode 100755 index 0000000..5677861 --- /dev/null +++ b/create.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +source .env +REPO_NAME=$(basename $(pwd)) +GITEA_USERNAME=aynish +CREATE_REPO=true + +curl -X POST -H "Content-Type: application/json" -d "{ \"name\": \"${REPO_NAME}\"}" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "https://git.sealight.xyz/api/v1/user/repo" + +if [ ${CREATE_REPO} ]; then + git init + git add . + git commit -m "Initial Commit" + git remote add "gitea@git.sealight.xyz:${GITEA_USERNAME}/${REPO_NAME}.git" + git push +fi diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..4c3238c --- /dev/null +++ b/env.sample @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Either copy this file, or create a new one with your password +# Rename the new file to .env +# DON'T PLACE IN GIT REPO +export GITEA_TOKEN=your-password-here