Clinical-Genomics / docker-base-images

A collection of useful images to be used as base images for Dockerfiles
MIT License
0 stars 0 forks source link

Automation! #4

Open dnil opened 2 years ago

dnil commented 2 years ago

This repo is missing CI automation! Would be neat to add in GitHub Actions to update DockerHub!

northwestwitch commented 2 years ago

You are welcome to open a PR to fix it! 😆

northwestwitch commented 2 years ago

Could be done with an action like this perhaps? What it does:

The problem is that you don't know which tag to push, apart from "latest"..

I haven't tested this, it's just a draft!

name: Build and push changed Docker images to Docker Hub

on:
  push:
    branches:
      - master

jobs:
  get_changed_images:
    runs-on: ubuntu-latest
    steps:
      - name: Check out git repository
        uses: actions/checkout@v2

      - name: Find changed .yml files
          id: files
          uses: Ana06/get-changed-files@v2.0.0
          with:
            filter: "*.yml"

  docker_build_n_push:
    needs: get_changed_images
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dockerfile: ${{jobs.get_changed_images.steps.files.outputs.all}}

    steps:
      - name: Check out git repository
        uses: actions/checkout@v2

      - name: Get image name
        id: image_name
        uses: mad9000/actions-find-and-replace-string@2
        source: ${{ matrix.dockerfile }}
        find: '.yml'
        replace: ''

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: ./
          file: ./${{steps.image_name.outputs.all}}/Dockerfile
          push: true
          tags: "clinicalgenomics/${{steps.image_name.outputs.all}}:latest" #How do you get to know if you should push tag 1.0, 2.0 etc here?