Skip to content

Commit 42febe2

Browse files
committed
Merge branch 'main' of https://github.com/pmc-tools/docker
2 parents a89bc7a + a4d084f commit 42febe2

2 files changed

Lines changed: 148 additions & 17 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
1-
name: CIonDocker
21

3-
on:
4-
push:
5-
branches: [ "main" ]
6-
pull_request:
7-
branches: [ "main" ]
8-
9-
jobs:
10-
11-
build:
12-
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- uses: actions/checkout@v4
17-
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag pmctools/umb:$(date +%s)
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
schedule:
10+
- cron: '26 8 * * *'
11+
push:
12+
branches: [ "main" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "main" ]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
25+
jobs:
26+
build:
27+
name: Build on ${{ matrix.platform }}
28+
runs-on: ${{ matrix.runs-on }}
29+
permissions:
30+
contents: read
31+
packages: write
32+
# This is used to complete the identity challenge
33+
# with sigstore/fulcio when running outside of PRs.
34+
id-token: write
35+
strategy:
36+
matrix:
37+
include:
38+
# Set defaults
39+
- runs-on: ubuntu-latest
40+
platform: linux/amd64
41+
- runs-on: ubuntu-24.04-arm
42+
platform: linux/arm64
43+
fail-fast: false
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
- name: Prepare
50+
run: |
51+
platform=${{ matrix.platform }}
52+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
53+
54+
- name: Docker meta
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ${{ env.IMAGE_NAME }}
59+
60+
# Login against a Docker registry except on PR
61+
# https://github.com/docker/login-action
62+
- name: Log into registry ${{ env.REGISTRY }}
63+
if: github.event_name != 'pull_request'
64+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
73+
- name: Build and push by digest
74+
id: build
75+
uses: docker/build-push-action@v6
76+
with:
77+
platforms: ${{ matrix.platform }}
78+
labels: ${{ steps.meta.outputs.labels }}
79+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
80+
push: ${{ github.event_name != 'pull_request' }}
81+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
82+
cache-from: type=gha
83+
cache-to: type=gha,mode=max
84+
85+
- name: Export digest
86+
run: |
87+
mkdir -p ${{ runner.temp }}/digests
88+
digest="${{ steps.build.outputs.digest }}"
89+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
90+
91+
- name: Upload digest
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: digests-${{ env.PLATFORM_PAIR }}
95+
path: ${{ runner.temp }}/digests/*
96+
if-no-files-found: error
97+
retention-days: 1
98+
99+
merge:
100+
runs-on: ubuntu-latest
101+
permissions:
102+
contents: read
103+
packages: write
104+
# This is used to complete the identity challenge
105+
# with sigstore/fulcio when running outside of PRs.
106+
id-token: write
107+
needs:
108+
- build
109+
steps:
110+
- name: Download digests
111+
uses: actions/download-artifact@v4
112+
with:
113+
path: ${{ runner.temp }}/digests
114+
pattern: digests-*
115+
merge-multiple: true
116+
117+
- name: Log into registry ${{ env.REGISTRY }}
118+
if: github.event_name != 'pull_request'
119+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
120+
with:
121+
registry: ${{ env.REGISTRY }}
122+
username: ${{ github.actor }}
123+
password: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Set up Docker Buildx
126+
uses: docker/setup-buildx-action@v3
127+
128+
- name: Docker meta
129+
id: meta
130+
uses: docker/metadata-action@v5
131+
with:
132+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
133+
tags: |
134+
type=ref,event=branch
135+
type=ref,event=pr
136+
type=semver,pattern={{version}}
137+
type=semver,pattern={{major}}.{{minor}}
138+
139+
- name: Create manifest list and push
140+
working-directory: ${{ runner.temp }}/digests
141+
run: |
142+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
143+
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
144+
145+
- name: Inspect image
146+
run: |
147+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
148+
#

0 commit comments

Comments
 (0)