-
Notifications
You must be signed in to change notification settings - Fork 11
65 lines (60 loc) · 3.4 KB
/
build-docker-images.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
name: Docker Image Builder
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/build-docker-images.yml'
- 'infra/**'
push:
branches:
- main
paths:
- '.github/workflows/build-docker-images.yml'
- 'infra/**'
permissions:
contents: read
packages: write
env:
TONGSUO_VERSION: 8.3.2
jobs:
# Build containers for x86
build:
runs-on: ${{ matrix.IMAGE.RUNNER }}
strategy:
fail-fast: false
matrix:
IMAGE:
- {TAG_NAME: "tongsuopy-manylinux2014:x86_64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux2014_x86_64", RUNNER: "ubuntu-latest"}
- {TAG_NAME: "tongsuopy-manylinux_2_24:x86_64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux_2_24_x86_64", RUNNER: "ubuntu-latest"}
- {TAG_NAME: "tongsuopy-manylinux_2_28:x86_64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux_2_28_x86_64", RUNNER: "ubuntu-latest"}
- {TAG_NAME: "tongsuopy-musllinux_1_1:x86_64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "musllinux_1_1_x86_64", RUNNER: "ubuntu-latest"}
- { TAG_NAME: "tongsuopy-manylinux2014:aarch64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux2014_aarch64", RUNNER: "ubuntu-latest" }
- { TAG_NAME: "tongsuopy-manylinux_2_24:aarch64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux_2_24_aarch64", RUNNER: "ubuntu-latest" }
- { TAG_NAME: "tongsuopy-manylinux_2_28:aarch64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "manylinux_2_28_aarch64", RUNNER: "ubuntu-latest" }
- { TAG_NAME: "tongsuopy-musllinux_1_1:aarch64", DOCKERFILE_PATH: "infra", PYCA_RELEASE: "musllinux_1_1_aarch64", RUNNER: "ubuntu-latest" }
name: "${{ matrix.IMAGE.TAG_NAME }}"
steps:
- uses: actions/[email protected]
# add --platform linux/amd64 to fix:
# The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
- id: set-up-qemu
name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Pull the previous image, but if it fails return true anyway.
# Sometimes we add new docker images and if they've never been pushed
# they can't be pulled.
- name: Pull existing image
run: docker pull ghcr.io/tongsuo-project/${{ matrix.IMAGE.TAG_NAME }} || true
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
- name: Build image
run: |
docker build --pull --cache-from ghcr.io/tongsuo-project/${{ matrix.IMAGE.TAG_NAME }} -t ghcr.io/tongsuo-project/${{ matrix.IMAGE.TAG_NAME }} --build-arg PYCA_RELEASE=${{ matrix.IMAGE.PYCA_RELEASE }} --build-arg TONGSUO_VERSION=${TONGSUO_VERSION} --build-arg TONGSUO_HOME=/opt/tongsuo${TONGSUO_VERSION} ${{ matrix.IMAGE.DOCKERFILE_PATH }}
- name: Login to docker
run: 'docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" ghcr.io'
env:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
- name: Push image
run: docker push ghcr.io/tongsuo-project/${{ matrix.IMAGE.TAG_NAME }}
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'