An open API service indexing awesome lists of open source software.

https://github.com/julienchastang/github-docker-automation

Automates cloning GitHub repos, building Docker images, and pushing to DockerHub.
https://github.com/julienchastang/github-docker-automation

Last synced: 2 months ago
JSON representation

Automates cloning GitHub repos, building Docker images, and pushing to DockerHub.

Awesome Lists containing this project

README

        

- [GitHub Docker Processor](#h-B0FEE104)
- [Features](#h-B46BEB64)
- [Prerequisites](#h-3479049B)
- [Installation](#h-37BEA592)
- [Usage](#h-3A9FCC1E)
- [Cleanup](#h-CF21FF2B)
- [Check Docker Digest](#h-A97A2D1E)
- [Optional Builds](#h-BE3EA4F8)

# GitHub Docker Processor

This Python script automates the process of cloning multiple GitHub repositories and their specified branches, building Docker images for them, and pushing these images to DockerHub.

## Features

Reads a YAML file containing a list of GitHub repositories and their respective branches. Builds Docker images from each branch and tags them according to the GitHub repository and branch name. Pushes Docker images to DockerHub.

## Prerequisites

- Python 3.x
- Git
- Docker
- pyyaml package for Python

## Installation

```sh
git clone https://github.com/julienchastang/github_docker_processor.git
cd github_docker_processor
pip install pyyaml
docker login
chmod +x github_docker_processor.py
```

## Usage

Create a YAML file:

```yaml
repositories:
- url: https://github.com/User/repo
branches:
- "5.4"
- "5.5"
- url: https://github.com/AnotherUser/another-repo
branches:
- master
- develop
```

Run the script:

```sh
sh github_docker_processor.py path_to_your_yaml_file.yaml
```

This script will ultimately push to DockerHub images that look like this:

```sh
docker push user/repo:5.4
docker push user/repo:5.5
docker push anotheruser/another-repo:master
docker push anotheruser/another-repo:develop
```

## Cleanup

The script will remove the cloned repositories from the local machine after each Docker image has been built and pushed.

# Check Docker Digest

This Python script is designed to check for updates to a specified Docker image according to a configuration file. It can send notifications of upstream image changes via email or ifttt. Here is an example configuration looking for updates to a Tomcat container:

```yaml
digest_file_path: "/tmp/tomcat-image-digest.txt"
repository: "library/tomcat"
tag: "8.5-jdk11"
target_architecture: "amd64"
sender: "[email protected]"
recipient: "[email protected]"
subject: "Upstream Tomcat Digest Updated"
ifttt_key: "https://maker.ifttt.com/trigger//with/key/your_ifttt_key_here"
```

You can put this Python script in cron, e.g.,

```sh
0 */12 * * * /home/user/github-docker-automation/check-docker-digest.py \
config.yml >> /tmp/tomcat-cron.out 2>&1
```

## Optional Builds

`check-docker-digest.py` can build and push updated images to DockerHub in response to upstream changes. To enable this feature, add an optional `github_docker_repo` key in the configuration, which should link to the repository settings used by `github_docker_processor.py`. For example:

```yml
github_docker_repos: "repos.yml"
```