-
Notifications
You must be signed in to change notification settings - Fork 6
70 lines (60 loc) · 2.22 KB
/
build_docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (C) 2023 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later
# This workflow uses actions that are not certified by GitHub.
# This workflow creates and publishes Docker images to GitHub Container Registry (GHCR) for Ubuntu 18 and Centos 7
# This Workflow is triggered when a main branch is pushed to or a pull request is merged to main if the pull request has the label 'rebuild_docker'.
name: Build & Publish Docker Ubuntu18 & CentOS7
on:
push:
branches:
- 'main'
paths: ['docker/**', 'Dockerfile', 'conda/**', 'Makefile', 'setup.py', 'environment.yml', 'environment-dev.yml']
pull_request:
branches:
- 'main'
types: [ labeled ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
if: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild_docker 🐋') || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
pull-requests: read
contents: read
packages: write
deployments: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Ubuntu Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/ubuntu18.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ubuntu18
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Centos Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/centos7.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:centos7
labels: ${{ steps.meta.outputs.labels }}