-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 3.29 KB
/
docker-publish.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
name: Unbuild Docker Environments
# This action builds Docker images of unibuild for
# various OSes and then pushes result to GitHub
# Container Registry.
on:
push:
branches: [ '*' ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ 'main' ]
env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_BASE: ${{ github.repository }}
jobs:
build:
# Iterates through each OS using a matrix strategy
# See https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
fail-fast: true
matrix:
os: [ 'el7', 'el8', 'el9', 'd10', 'd11', 'd12', 'u18', 'u20', 'u22' ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}/${{ matrix.os }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker images
id: build-and-push
if: ${{ matrix.os == 'el7' || matrix.os == 'el8' || matrix.os == 'el9' }}
uses: docker/build-push-action@v3
with:
context: .
file: ./docker-envs/Dockerfile-${{ matrix.os }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker multiarch images
id: build-and-push-multiarch
if: ${{ matrix.os == 'd10' || matrix.os == 'd11' || matrix.os == 'd12' || matrix.os == 'u18' || matrix.os == 'u20' || matrix.os == 'u22' }}
uses: docker/build-push-action@v3
with:
context: .
file: ./docker-envs/Dockerfile-${{ matrix.os }}
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}