-
Notifications
You must be signed in to change notification settings - Fork 16
131 lines (114 loc) · 4.94 KB
/
build-publish-containers.yml
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Build and publish EESSI container images
on:
push:
branches:
- main
paths:
- containers/Dockerfile.EESSI-*
- containers/build-or-download-cvmfs-*.sh
pull_request:
branches:
- main
paths:
- containers/Dockerfile.EESSI-*
- containers/build-or-download-cvmfs-*.sh
# also rebuild the containers for new releases of filesystem-layer:
# this often means that we have a new CVMFS configuration package
release:
types: [published]
# Declare default permissions as read only.
permissions: read-all
jobs:
build_and_publish:
name: Build and publish image
runs-on: self-hosted
timeout-minutes: 720
permissions:
packages: write
contents: read
strategy:
matrix:
tag: ['client:centos7', 'build-node:debian11', 'build-node:debian-sid']
platform: [amd64, arm64, riscv64]
exclude:
# exclude images that don't support RISC-V
- tag: client:centos7
platform: riscv64
- tag: build-node:debian11
platform: riscv64
steps:
- name: Check out the repo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1
- name: Cache Docker layers
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.platform }}-${{ matrix.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.platform }}-${{ matrix.tag }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert and store repository owner in lowercase, replace colon in tag names by hyphen
run: |
echo REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
tag=${{ matrix.tag }}
echo DOCKERFILE=Dockerfile.EESSI-${tag//:/-} >> $GITHUB_ENV
- name: Build and push to GitHub Packages
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 #v3.2.0
with:
tags: ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-${{ matrix.platform }}
file: containers/${{ env.DOCKERFILE }}
platforms: linux/${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
create_multiplatform_image:
name: Create the multi-platform Docker image
needs: build_and_publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
tag: ['client:centos7', 'build-node:debian11', 'build-node:debian-sid']
steps:
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert and store repository owner in lowercase
run: |
echo REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Create the final image using "docker buildx imagetools create"
if: github.event_name != 'pull_request' && matrix.tag == 'build-node:debian-sid'
run: |
docker buildx imagetools create -t ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }} \
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64 \
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64 \
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-riscv64
- name: Create the final image using "docker buildx imagetools create"
if: github.event_name != 'pull_request' && matrix.tag != 'build-node:debian-sid'
run: |
docker buildx imagetools create -t ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }} \
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64 \
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64
- name: Inspect the final image
if: github.event_name != 'pull_request'
run: docker buildx imagetools inspect ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}