Skip to content

sumanchapai/gw

Repository files navigation

GW is a webserver that provides basic git functionalities via HTTP endpoints.

Motivation:

For small, single user web apps, I use text-based databases. For example, JSON, or YAML files. Similarly, the accounting software that I use, beancount, is also text-based. This has benefits like easy version control (simply using git) and high fault tolerance (push to github). This app is a webserver that gives you buttons to run git commit and git push so that those who use these web apps don't have to open a terminal to backup their "database".

Web view of gw app

Usage:

The most standard way to run this project is via docker (unless you're doing project development).

  1. Go to the folder that you want to run git commands from Web browser.
  2. Copy .env.example from this project repo and save it as .env into your folder.
  3. Copy compose.yaml from this project repo and save it to your folder.
  4. Update the environment variables as needed. See below on how to set a github token.
  5. Run docker compose up. Add the -d flag at the end if you want run in detached mode.
  6. Set the restart flag in docker-compose.yaml to always if this is a service to automatically start on system startup.
  7. Visit localhost:8071 or whatever PORT, if you updated that in the environment file.

Environment Variables

Check the sample .env.example file for what kinds of environment variables you can use.

Development

  1. Clone this repo.
  2. Have go mentioned in go.mod or higher installed.
  3. In the root directory of this project, run go install .
  4. Navigate to the folder that you want to expose through this server.
  5. Run git init if this folder isn't a git repo already.
  6. Create .env file in the root of this folder, mentioning the absolute path to this folder as value to the variable GW_REPO.
  7. Optionally, set HOST and PORT environment variables as necessary.
  8. Run gw.

Generating Github Token:

  1. Go to https://github.com/settings/personal-access-tokens/
  2. On the left sidebar, make sure "Fine-grained tokens" is selected.
  3. Click Generate New Token.
  4. Fill up the token name, description, fields etc.
  5. Set the expiration to "No expiration" or whatever you prefer.
  6. Select "Only select repository" and select the repo you want to give access to.
  7. On the bottom box, click on add permissions select "Contents"
  8. Give contents Read and Write access and save the token in the .env file in the TOKEN variable.

Running purely locally

By default, your server will listen on all interfaces meaning that others connected to the same network (Wifi) as you will be able to access your server by your IP:PORT web address. If you want to run only in localhost, change your PORT by prepending local IP as follows:

PORT=127.0.0.1:8063

About

use (simplified) git from the browser

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors