This is binary allows serving selective content of a Git repository. The user can access those files per branch or tag.
This was originally built for publishing up-to-date JSONSchema files per version.
- Set up a static file mirror of your Git Repository
- Limit display to specific files
- Make files accessible per branch or tag
You may use the binaries from our release section, build one yourself or use our pre-made Docker container.
Webserver is served at port 8080.
docker run -p 8080:80 -v "`pwd`/config.yml.dist":/config/config.yml saitho/git-file-webserver:latest
Requires Git to be installed! Webserver is served at port 8080.
./git-file-webserver -p 8080 -c config.yml.dist
The config.yml file is used to configure the repository that should be displayed.
It can also be used to limit the displayed files or set a work directory.
Inside the git section you have to set the path to your repository in url setting.
Additionally you may set a work_dir, which means that only the files in this directory are considered to be served.
Note: As of right now this is a global option. Keep that in mind if the folder name changes in releases or branches.
Updating the repository can be done two ways: time-based (cache-like) or webhook-based (mirror-like).
Setting the update.mode to "cache" will refresh the repository every hour (per default).
You may change the update time by setting update.cache.time (in seconds).
Setting the update.mode to "webhook_github" will refresh the repository on new commits or tags to the repository.
The repository needs to be setup manually for that (see below).
---
git:
url: https://github.com/getstackhead/stackhead.git
work_dir: schemas
update:
mode: cache # either "cache" (default) or "webhook_github"
cache:
time: 3600 # default: 60 minutes
webhook:
github:
secret: foobar # secret to be used with GitHub webhookThe files section is an array of fileglobs you can use to specify which files should be displayed.
In the example below, only JSON files are served. So files that do not end with .json and folders not containing .json files are not displayed.
---
files:
- "**/*.json"In the display section you can define how the frontend should look like.
You may change the order of tags or hide the tag date in tags subsection.
You can also toggle the display of branches or tags for the index page in the index subsection.
---
display:
tags:
order: desc
show_date: true
index:
show_branches: true
show_tags: trueIf you want to update the repository whenever something is pushed or tagged in your repository, you can use GitHub webhooks.
Set the mode in git.update subsection to "webhook_github" and define a secret.
---
git:
update:
mode: webhook_github
webhook:
github:
secret: your-secret-hereThen, create your webhook on GitHub as follows:
- Go to your Repository Settings
- Select the "Webhooks" option in the left navigation menu
- Click the button "Add webhook" at the top right
- Add set your server URL as "Payload URL" (ending with
/webhook), e.g.https://schema.stackhead.io/webhook - Select "application/json" as "Content type"
- Set your secret from configuration as "Secret"
- Choose the option "Let me select individual events." and enable the folowing events:
- Branch or tag creation
- Branch or tag deletion
- Pushes
You're ready to go. New changes to your repository should be mirrored automatically to your webserver.