Final changes

Signed-off-by: Jonas Franz <info@jonasfranz.software>
pull/18/head
Jonas Franz 6 years ago
parent 7114f1018b
commit 9d872dcf75
Signed by: JonasFranzDEV
GPG Key ID: 506AEEBE80BEDECD
  1. 15
      .drone.yml
  2. 2
      Dockerfile
  3. 23
      Dockerfile.web
  4. 39
      Makefile
  5. 61
      README.md
  6. 12
      cmd/web.go
  7. 9
      config.example.yml
  8. 1
      config/config.go
  9. 4
      web/context/context.go
  10. 6
      web/templates/base/head.tmpl
  11. 14
      web/templates/status/403.tmpl
  12. 14
      web/templates/status/404.tmpl
  13. 14
      web/templates/status/500.tmpl
  14. 14
      web/templates/status/unknown_error.tmpl

@ -25,7 +25,7 @@ pipeline:
environment:
GOPATH: /go
commands:
- make test
- make test build
static:
image: golang:1.10
pull: true
@ -70,11 +70,20 @@ pipeline:
image: plugins/docker:17.12
secrets: [ docker_username, docker_password ]
pull: true
repo: jonasfranz/gitea-github-migrator
repo: ggmigrator/cli
default_tags: true
when:
event: [ push, tag ]
docker-web:
image: plugins/docker:17.12
secrets: [ docker_username, docker_password ]
pull: true
dockerfile: Dockerfile.web
repo: ggmigrator/web
default_tags: true
when:
event: [ push, tag ]
branch: [ master ]
s3:
image: plugins/s3:1
pull: true

@ -2,7 +2,7 @@
FROM golang:1.10-alpine3.7 AS build-env
#Build deps
RUN apk --no-cache add build-base git
RUN apk --no-cache add build-base git ca-certificates
#Setup repo
COPY . ${GOPATH}/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator

@ -0,0 +1,23 @@
#Build stage
FROM golang:1.10-alpine3.7 AS build-env
#Build deps
RUN apk --no-cache add build-base git ca-certificates
#Setup repo
COPY . ${GOPATH}/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator
WORKDIR ${GOPATH}/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator
RUN make clean docker-binary-web
FROM alpine:3.7
LABEL maintainer="info@jonasfranz.software"
COPY --from=build-env /go/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/gitea-github-migrator /usr/local/bin/gitea-github-migrator
VOLUME "/data"
VOLUME "/usr/local/bin/data"
COPY --from=build-env /go/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/config.example.yml /data/config.example.yml
ENTRYPOINT ["/usr/local/bin/gitea-github-migrator", "web", "-c", "/data/config.yml"]

@ -17,19 +17,50 @@ LDFLAGS := -X main.version=$(VERSION) -X main.build=$(DRONE_BUILD_NUMBER)
.PHONY: all
all:
.PHONY: docker-binary
docker-binary:
.PHONY: build
go build -ldflags "$(LDFLAGS)" -o gitea-github-migrator
.PHONY: docker-binary-web
.PHONY: build-binary-web
build-binary-web:
go build -ldflags "$(LDFLAGS)" -tags web -o gitea-github-migrator
.PHONY: build-web
build-web: packr build-binary-web packr-clean
.PHONY: packr
packr:
@hash packr > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/gobuffalo/packr/...; \
fi
packr -z
.PHONY: packr-clean
packr-clean:
@hash packr > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/gobuffalo/packr/...; \
fi
packr clean
.PHONY: clean
clean: packr-clean
go clean ./...
.PHONY: docker-binary
docker-binary: build
.PHONY: docker-binary-web
docker-binary-web: build-web
.PHONY: generate-release-file
generate-release-file:
echo $(VERSION) > .version
.PHONY: release
release:
release: packr release-builds packr-clean
.PHONY: release-builds
release-builds:
@hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/mitchellh/gox; \
fi

@ -2,7 +2,8 @@
[![Build Status](https://drone.jonasfranz.software/api/badges/JonasFranzDEV/gitea-github-migrator/status.svg)](https://drone.jonasfranz.software/JonasFranzDEV/gitea-github-migrator)
[![Latest Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https%3A%2F%2Fgit.jonasfranz.software%2Fapi%2Fv1%2Frepos%2FJonasFranzDEV%2Fgitea-github-migrator%2Freleases&query=%24%5B0%5D.tag_name)](https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/releases)
[![Docker Pulls](https://img.shields.io/docker/pulls/jonasfranz/gitea-github-migrator.svg)](https://hub.docker.com/r/jonasfranz/gitea-github-migrator/)
[![Docker Pulls](https://img.shields.io/docker/pulls/ggmigrator/cli.svg)](https://hub.docker.com/r/ggmigrator/cli/)
[![Docker Pulls](https://img.shields.io/docker/pulls/ggmigrator/web.svg)](https://hub.docker.com/r/ggmigrator/web/)
A tool to migrate [GitHub](https://github.com) Repositories to [Gitea](https://gitea.io) including all issues, labels, milestones
and comments.
@ -28,8 +29,11 @@ Migrates:
go get git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator
cd $GOPATH/src/git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator
dep ensure
go install
make build
```
#### Web Support
Run `make web-build` instead of `make build` to include web support.
### From Binary
We provide binaries of master builds and all releases at our [minio storage server](https://storage.h.jonasfranz.software/minio/gitea-github-migrator/dist/).
@ -37,8 +41,28 @@ We provide binaries of master builds and all releases at our [minio storage serv
Additionally we provide them for every release as release attachment under [releases](https://git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/releases).
You don't need any dependencies except the binary to run the migrator.
These binaries include web support by default.
### From Docker image
We provide a [cli docker image](https://hub.docker.com/r/ggmigrator/cli/):
For master builds:
```docker
docker run ggmigrator/cli:latest
```
For release builds:
```docker
docker run ggmigrator/cli:0.0.9
```
## Usage
### Command line
Migrate one repository:
```bash
@ -75,6 +99,39 @@ gitea-github-migrator migrate-all \
--only-repo
```
### Web interface
Since 0.1.0 gitea-github-migrator comes with an integrated web interface.
Follow these steps to get the web interface running:
1. Download or build a web-capable binary of the gitea-github-migrator. The builds on our storage server are build with web support included.
If you build from source, please follow [web support](#web-support).
2. Create `config.yml` file and change the properties according to your wishes. Please keep in mind that
you have to create a GitHub OAuth application to make the web interface work.
3. Run `./gitea-github-migrator web`
4. Visit `http://localhost:4000`
#### Docker
We're providing a docker image with web support. To start the web service please run:
```docker
docker run ggmigrator/web -p 4000:4000 -v data/:/data
```
Place your `config.yml` into `data/config.yml`.
#### Config
Example:
```yaml
# GitHub contains the OAuth2 application data obtainable from GitHub
GitHub:
client_id: GITHUB_OAUTH_CLIENT_ID
client_secret: GITHUB_OAUTH_SECRET
# Web contains the configuration for the integrated web server
Web:
port: 4000
host: 0.0.0.0
```
## Problems
- This migration tool does not work with Gitea instances using a SQLite database.

@ -18,10 +18,18 @@ var CmdWeb = cli.Command{
Name: "web",
Usage: "Starts the web interface",
Action: runWeb,
Flags: []cli.Flag{
cli.StringFlag{
Name: "c,config",
Usage: "config file",
Value: "config.yml",
EnvVar: "MIGRATOR_CONFIG",
},
},
}
func runWeb(_ *cli.Context) error {
if err := configor.New(&configor.Config{ErrorOnUnmatchedKeys: true}).Load(&config.Config, "config.yml"); err != nil {
func runWeb(ctx *cli.Context) error {
if err := configor.New(&configor.Config{ErrorOnUnmatchedKeys: true}).Load(&config.Config, ctx.String("config")); err != nil {
return err
}
r := web.InitRoutes()

@ -1,3 +1,8 @@
# GitHub contains the OAuth2 application data obtainable from GitHub
GitHub:
client_id: heöll
client_secret: secret
client_id: GITHUB_OAUTH_CLIENT_ID
client_secret: GITHUB_OAUTH_SECRET
# Web contains the configuration for the integrated web server
Web:
port: 4000
host: 0.0.0.0

@ -10,5 +10,4 @@ var Config = struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
}
Secret string `required:"true"`
}{}

@ -10,6 +10,7 @@ import (
"git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/migrations"
"github.com/go-macaron/session"
"github.com/google/go-github/github"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"gopkg.in/macaron.v1"
)
@ -56,9 +57,12 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.Data["ErrorMsg"] = err
}
}
logrus.Warnf("Handle: %v", err)
ctx.Data["ErrTitle"] = title
switch status {
case 403:
ctx.Data["Title"] = "Access denied"
case 404:
ctx.Data["Title"] = "Page not found"
case 500:

@ -9,9 +9,9 @@
<!-- Site Properties -->
<title>Gitea Migrator</title>
<script src="static/js/jquery-3.1.1.min.js"></script>
<script src="static/js/semantic.min.js"></script>
<link href="static/css/semantic.min.css" rel="stylesheet">
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/semantic.min.js"></script>
<link href="/static/css/semantic.min.css" rel="stylesheet">
<style type="text/css">
body {
background-color: #DADADA;

@ -0,0 +1,14 @@
{{template "base/head" .}}
<div class="ui middle aligned center aligned grid">
<div class="column">
<h1 class="ui image header">
<div class="content">
Access denied
</div>
</h1>
<div class="ui error message">
{{.ErrTitle}}
</div>
</div>
</div>
{{template "base/footer" .}}

@ -0,0 +1,14 @@
{{template "base/head" .}}
<div class="ui middle aligned center aligned grid">
<div class="column">
<h1 class="ui image header">
<div class="content">
Error 404 - Not found
</div>
</h1>
<div class="ui error message">
{{.ErrTitle}}
</div>
</div>
</div>
{{template "base/footer" .}}

@ -0,0 +1,14 @@
{{template "base/head" .}}
<div class="ui middle aligned center aligned grid">
<div class="column">
<h1 class="ui image header">
<div class="content">
Error 500 - Internal Server Error
</div>
</h1>
<div class="ui error message">
{{.ErrTitle}}
</div>
</div>
</div>
{{template "base/footer" .}}

@ -0,0 +1,14 @@
{{template "base/head" .}}
<div class="ui middle aligned center aligned grid">
<div class="column">
<h1 class="ui image header">
<div class="content">
Unknown Error
</div>
</h1>
<div class="ui error message">
{{.ErrTitle}}
</div>
</div>
</div>
{{template "base/footer" .}}
Loading…
Cancel
Save