-
Notifications
You must be signed in to change notification settings - Fork 5
104 lines (98 loc) · 3.57 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
name: Build and publish container images
on: [push, pull_request, workflow_dispatch]
jobs:
build_publish:
name: Build/publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
tag:
- centos-7.9-python3
- centos-7.9
- centos-8.5
- centosstream-9
- fedora-35
- fedora-36
- opensuse-15.3
- opensuse-15.4
- rockylinux-8.5
- rockylinux-8.6
- rockylinux-8.7
- rockylinux-8.8
- rockylinux-8.9
- rockylinux-9.0
- rockylinux-9.1
- rockylinux-9.2
- rockylinux-9.3
- almalinux-8.6
- almalinux-9.0
- ubuntu-20.04
- ubuntu-20.04-python2
- ubuntu-22.04
- ubuntu-24.04
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.tag }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' && github.ref_name == 'main'
uses: docker/login-action@v2
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
echo IMAGE_TAG=$(date +"%F")-${{ github.run_id }}.${{ github.run_number }} >> $GITHUB_ENV
- name: Build and push to GitHub Packages
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: |
linux/amd64
linux/arm64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
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
- name: Build and push to amd64
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: linux/amd64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-from: type=local,src=/tmp/.buildx-cache
- name: Build and push to arm64
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: linux/arm64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-from: type=local,src=/tmp/.buildx-cache