Skip to content

Commit db4c210

Browse files
authored
changes in ci (#604)
* build docker images also for pull-requests * split docker builds via matrix per platform
1 parent 0b8394c commit db4c210

4 files changed

Lines changed: 124 additions & 93 deletions

File tree

.github/workflows/ci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
13+
env:
14+
REGISTRY_IMAGE: ${{ github.repository }}
15+
16+
jobs:
17+
18+
test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- name: Setup Ruby
24+
uses: ruby/setup-ruby@v1
25+
- name: Install Dependencies
26+
run: bundle install
27+
- name: Execute Tests
28+
run: bundle exec rspec
29+
30+
build:
31+
runs-on: ubuntu-latest
32+
needs:
33+
- test
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
platform:
38+
- linux/amd64
39+
- linux/arm/v7
40+
- linux/arm64
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
- name: Docker meta
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: |
49+
${{ env.REGISTRY_IMAGE }}
50+
tags: |
51+
type=ref,event=branch
52+
type=ref,event=pr
53+
type=semver,pattern={{version}}
54+
type=semver,pattern={{major}}.{{minor}}
55+
- name: Set up QEMU
56+
uses: docker/setup-qemu-action@v3
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
- name: Login to Docker Hub
60+
uses: docker/login-action@v3
61+
with:
62+
username: ${{ secrets.DOCKERHUB_USERNAME }}
63+
password: ${{ secrets.DOCKERHUB_TOKEN }}
64+
- name: Build and push by digest
65+
id: build
66+
uses: docker/build-push-action@v5
67+
with:
68+
context: .
69+
build-args: |
70+
SOURCE_COMMIT=${{ github.sha }}
71+
platforms: ${{ matrix.platform }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
74+
- name: Export digest
75+
run: |
76+
mkdir -p /tmp/digests
77+
digest="${{ steps.build.outputs.digest }}"
78+
touch "/tmp/digests/${digest#sha256:}"
79+
- name: Upload digest
80+
uses: actions/upload-artifact@v3
81+
with:
82+
name: digests
83+
path: /tmp/digests/*
84+
if-no-files-found: error
85+
retention-days: 1
86+
87+
publish:
88+
if: github.event_name != 'pull_request'
89+
runs-on: ubuntu-latest
90+
needs:
91+
- build
92+
steps:
93+
- name: Download digests
94+
uses: actions/download-artifact@v3
95+
with:
96+
name: digests
97+
path: /tmp/digests
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
- name: Docker meta
101+
id: meta
102+
uses: docker/metadata-action@v5
103+
with:
104+
images: |
105+
${{ env.REGISTRY_IMAGE }}
106+
tags: |
107+
type=ref,event=branch
108+
type=ref,event=pr
109+
type=semver,pattern={{version}}
110+
type=semver,pattern={{major}}.{{minor}}
111+
- name: Login to Docker Hub
112+
uses: docker/login-action@v3
113+
with:
114+
username: ${{ secrets.DOCKERHUB_USERNAME }}
115+
password: ${{ secrets.DOCKERHUB_TOKEN }}
116+
- name: Create manifest list and push
117+
working-directory: /tmp/digests
118+
run: |
119+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
120+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
121+
- name: Inspect image
122+
run: |
123+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
124+

.github/workflows/docker-on-push.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/docker-on-release.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/ruby.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)