diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9243bd5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: +- package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + reviewers: + - pehbehbeh + assignees: + - pehbehbeh diff --git a/.github/workflows/Edge.yml b/.github/workflows/Edge.yml new file mode 100644 index 0000000..50a4f51 --- /dev/null +++ b/.github/workflows/Edge.yml @@ -0,0 +1,35 @@ +name: Build and push edge image + +on: + push: + branches: + - develop + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + sourceboat/docker-compose-githooks:edge diff --git a/.github/workflows/Stable.yml b/.github/workflows/Stable.yml new file mode 100644 index 0000000..cdcf6b7 --- /dev/null +++ b/.github/workflows/Stable.yml @@ -0,0 +1,47 @@ +name: Build and push stable image + +on: + push: + tags: + - '*.*.*' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Docker meta builder + id: meta + uses: docker/metadata-action@v3 + with: + images: | + sourceboat/docker-compose-githooks + flavour: | + latest=true + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 25c37c6..973b7e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ -FROM busybox:latest +FROM busybox:1.34.1 ENTRYPOINT sh -c "cd /tmp/.githooks && ls | xargs chmod +x && cd /tmp/.git/hooks && find ../../.githooks -type f -exec ln -sf {} /tmp/.git/hooks/ \; && echo 'githooks installed'" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ef31d90 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) Sourceboat GmbH & Co. KG + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..830da6f --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# docker-compose-githooks + +[![Docker Build Status](https://img.shields.io/docker/cloud/build/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://hub.docker.com/r/sourceboat/docker-compose-githooks/builds/) +[![Release](https://img.shields.io/github/release/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://github.com/sourceboat/docker-compose-githooks/releases) +[![Docker Pulls](https://img.shields.io/docker/pulls/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://hub.docker.com/r/sourceboat/docker-compose-githooks/) +[![Image Size](https://img.shields.io/docker/image-size/sourceboat/docker-compose-githooks?style=flat-square)](https://microbadger.com/images/sourceboat/docker-compose-githooks) +[![MicroBadger Layers](https://img.shields.io/microbadger/layers/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://microbadger.com/images/sourceboat/docker-compose-githooks) + +Easily manage and version control [Git Hooks](https://git-scm.com/book/de/v1/Git-individuell-einrichten-Git-Hooks) +in a [Docker Compose](https://docs.docker.com/compose/) setup. + +## Usage + +Add a new service to your `.docker-compose.yml` file: + +```yml +version: '3.7' +services: + + // ... + + githooks: + image: sourceboat/docker-compose-githooks:latest + volumes: + - ./.git:/tmp/.git + - ./.githooks:/tmp/.githooks +``` + +Now you can manage and version control your Git Hooks in the `.githooks` directory of your repository. +Everytime you run `docker-compose up` the `githooks` service will create symlinks in `.git/hooks` to all files found in the `.githooks` directory. + +For example you can create a `.githooks/pre-commit` file to run your linters inside your running containers: + +```sh +#!/bin/sh +echo 'running pre-commit hook...' +docker-compose exec -T app yarn lint +``` + +## Changelog + +Check [releases](https://github.com/sourceboat/docker-compose-githooks/releases) for all notable changes. + +## Credits + +- This project is based on [an article by Aurélien Hervé](https://hackernoon.com/using-git-hooks-in-a-dockerized-environment-55372c40815f). +- [Phil-Bastian Berndt](https://github.com/pehbehbeh) +- [All Contributors](https://github.com/sourceboat/docker-compose-githooks/graphs/contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/readme.md b/readme.md deleted file mode 100644 index ccf8485..0000000 --- a/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# docker-compose-githooks - -[![Docker Build Status](https://img.shields.io/docker/automated/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://hub.docker.com/r/sourceboat/docker-compose-githooks/builds/) -[![Release](https://img.shields.io/github/release/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://github.com/sourceboat/docker-compose-githooks/releases) -[![Docker Pulls](https://img.shields.io/docker/pulls/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://hub.docker.com/r/sourceboat/docker-compose-githooks/) -[![MicroBadger Size](https://img.shields.io/microbadger/image-size/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://microbadger.com/images/sourceboat/docker-compose-githooks) -[![MicroBadger Layers](https://img.shields.io/microbadger/layers/sourceboat/docker-compose-githooks.svg?style=flat-square)](https://microbadger.com/images/sourceboat/docker-compose-githooks) - -Easily manage [Git Hooks](https://git-scm.com/book/de/v1/Git-individuell-einrichten-Git-Hooks) -in a [Docker Compose](https://docs.docker.com/compose/) setup.