-
Notifications
You must be signed in to change notification settings - Fork 31
111 lines (99 loc) · 3.75 KB
/
build_containers.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Build container image for GHCR
on:
push:
branches:
- devel
- RELEASE_*
workflow_dispatch:
schedule:
- cron: '0 18 * * 5'
jobs:
build:
strategy:
fail-fast: false
matrix:
base:
- {image: 'rocker/r-ver', amdtag: '4.2.3', armtag: '4.2.3', outname: 'r-ver'}
- {image: 'rocker/rstudio', amdtag: '4.2.3', armtag: 'N/A', outname: 'bioconductor_docker'}
- {image: 'rocker/tidyverse', amdtag: '4.2.3', armtag: 'N/A', outname: 'tidyverse'}
- {image: 'rocker/ml-verse', amdtag: '4.2.3', armtag: 'N/A', outname: 'ml-verse'}
name: Build branch images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Free root space
uses: almahmoud/free-root-space@main
with:
verbose: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata for container image
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository_owner }}/${{ matrix.base.outname }}
tags: |
type=raw,value={{branch}}
- name: Set comma-separated list with all repository names
id: images
run: |
IMG=${{ steps.meta.outputs.tags }}
REPOLIST="docker.io/$IMG"
REPOLIST="ghcr.io/$IMG,$REPOLIST"
# Add tag with tag 3.xx as well as RELEASE_3_xx
if [[ $IMG = *"RELEASE_"* ]]; then
REPOLIST="$(echo $REPOLIST | sed 's/:RELEASE_3_/:3./g'),$REPOLIST"
fi
# Add tag with R version (based on amd64)
docker pull ${{ matrix.base.image }}:${{ matrix.base.amdtag }}
RVER=$(docker inspect ${{ matrix.base.image }}:${{ matrix.base.amdtag }} | jq -r '.[].Config.Env[]|select(match("^R_VERSION"))|.[index("=")+1:]')
REPOLIST="$(echo $REPOLIST | sed "s/,/-R-$RVER,/g")-R-$RVER,$REPOLIST"
# Also add alternative without _docker when in name
if [[ $REPOLIST == *"_docker"* ]]; then
REPOLIST="$(echo $REPOLIST | sed 's/_docker//g'),$REPOLIST"
fi
echo list=$REPOLIST >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Build and push container image to all repos both arm64 and amd64
uses: docker/build-push-action@v3
with:
build-args: |
BASE_IMAGE=${{ matrix.base.image }}
arm64_tag=${{ matrix.base.armtag }}
amd64_tag=${{ matrix.base.amdtag }}
file: Dockerfile
push: true
tags: ${{ steps.images.outputs.list }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
if: matrix.base.armtag != 'N/A'
- name: Build and push container image to all repos amd64 only
uses: docker/build-push-action@v3
with:
build-args: |
BASE_IMAGE=${{ matrix.base.image }}
amd64_tag=${{ matrix.base.amdtag }}
file: Dockerfile
push: true
tags: ${{ steps.images.outputs.list }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
if: matrix.base.armtag == 'N/A'