s3push

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2016 License: MIT Imports: 15 Imported by: 1

README

git-s3-push

git-s3-push is a tool to deploy git repositories to AWS S3 buckets. git-s3-push keeps track of which commits have been pushed and supports deploying only recently modified files. It can be used for deploying static websites hosted on S3, maintaining versioned bucket data or using S3 to backup git repositories.

Features

  • Simple method to deploy git repos to S3.
  • Fast uploads by only uploading new commits.
  • Automatically detects and sets the S3 content type of files.
  • Can automatically make your files publicly available (private by default).
  • Single binary, no dependencies on language runtimes.

Installation

Grab a binary for your platform from the releases. Or check out the code, run go get and go run git-s3-push.go.

Git must be installed on your path.

Dependencies

On Unix-like platforms (Linux, Mac OS, BSDs etc.) git-s3-push depends on magicmime for file content-type detection, which in turn depends on libmagic. On Arch install the file package, on Debian based systems you need libmagic1 and libmagic-devel, on Mac OS run brew install libmagic. This is not required on Windows, which uses Golang's built-in mimetype detection.

Usage

Authentication credentials are taken from the standard AWS environment variables. Bucket name and AWS region are supplied as arguments.

$ export AWS_ACCESS_KEY_ID=<...>

$ export AWS_SECRET_ACCESS_KEY=<...>

$ git-s3-push -b my-bucket-name -r aws-region-1 -save

The -save flag stores the bucket name and region so you can push to the same location by just running:

$ git-s3-push

The -public flag can be used to make the files uploaded to your bucket publicly readable. When running without the -public flag, pushed files are stored privately.

All usage options can be shown using the -help flag.

Config

After using the -save flag, git-s3-push creates a JSON configuration file (.git_s3_push) storing bucket and region information. This file also includes other configuration directives that cannot be specified using flags:

  • Ignore: Files in the git repo that should not be pushed. This could include source files (for example .coffee files), or any other file in the git repository you don't want pushed to the S3 bucket. Files are specified in a JSON list of regexes. For example: "Ignore":["src/*.coffee"]

  • IncludeNonGit: Files not tracked by git that should be pushed to the destination bucket. Files are specified in a JSON list of paths. Paths can be absolute or relative to the root of the git repository.

License

  • MIT license. See the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct {
	GitRepo        *gogit.Repository
	HeadCommit     *gogit.Commit
	LastPushCommit *gogit.Commit
	UnpushedFiles  mapset.Set
	Config         repoConfig
	IgnoreRegexes  []*regexp.Regexp
	// contains filtered or unexported fields
}

Repository represents a git-s3-push enabled git repository

func OpenRepository

func OpenRepository() (*Repository, error)

OpenRepository opens and initialises a 'git-s3-push' enabled git repository

func (*Repository) CompileIgnoreRegexes

func (repo *Repository) CompileIgnoreRegexes() error

CompileIgnoreRegexes compiles the regexes in the Ignore configuration directive

func (*Repository) FindCommitModifiedFiles

func (repo *Repository) FindCommitModifiedFiles(commit *gogit.Commit) error

FindCommitModifiedFiles finds files modified in given commit

func (*Repository) FindRelevantCommits

func (repo *Repository) FindRelevantCommits() error

FindRelevantCommits calls git to find commits not pushed to S3

func (*Repository) FindUnpushedModifiedFiles

func (repo *Repository) FindUnpushedModifiedFiles() error

FindUnpushedModifiedFiles finds files that have been modified since last push to S3

func (*Repository) ReadConfigFile

func (repo *Repository) ReadConfigFile() error

ReadConfigFile reads .git_s3_push configuration file from repo

func (*Repository) ReadGitModifiedFiles

func (repo *Repository) ReadGitModifiedFiles(scanner *bufio.Scanner)

ReadGitModifiedFiles reads the git output describe files modified since last S3 push

func (Repository) SaveConfigToFile

func (repo Repository) SaveConfigToFile() error

SaveConfigToFile marshals the current configuration to JSON and saves it to .git_s3_push

func (Repository) UpdateGitLastPushRef

func (repo Repository) UpdateGitLastPushRef() error

UpdateGitLastPushRef sets the git-s3-push branch to the latest commit pushed

type S3Uploader

type S3Uploader struct {
	// contains filtered or unexported fields
}

S3Uploader manages S3 uploads to a specific bucket

func InitS3Uploader

func InitS3Uploader(config repoConfig) (*S3Uploader, error)

InitS3Uploader initializes a new S3Uploader

func (S3Uploader) Close added in v0.2.0

func (uploader S3Uploader) Close()

Close cleans up the uploader

func (S3Uploader) UploadFile

func (uploader S3Uploader) UploadFile(path string) error

UploadFile uploads a file to S3

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL