Skip to content

Commit b1a213e

Browse files
authored
Merge pull request #6 from LinuxSuRen/github-action
Using GitHub actions to build multi-arch images
2 parents 8e0e5a4 + 3e0e9aa commit b1a213e

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/build.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Image Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- test-* # make it be easier for contributors to test
8+
tags:
9+
- 'v*.*.*'
10+
pull_request:
11+
branches:
12+
- 'master'
13+
14+
jobs:
15+
Build:
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Docker meta for KubeSphere
20+
id: meta
21+
if: github.repository_owner == 'kubesphere'
22+
uses: docker/metadata-action@v3
23+
with:
24+
images: |
25+
kubespheredev/s2i-binary
26+
ghcr.io/${{ github.repository_owner }}/s2i-binary
27+
tags: |
28+
type=schedule
29+
type=ref,event=branch
30+
type=ref,event=pr
31+
type=semver,pattern=v{{version}}
32+
type=semver,pattern=v{{major}}.{{minor}}
33+
type=semver,pattern=v{{major}}
34+
type=sha
35+
- name: Docker meta for Contributors
36+
id: metaContributors
37+
if: github.repository_owner != 'kubesphere'
38+
uses: docker/metadata-action@v3
39+
with:
40+
images: |
41+
ghcr.io/${{ github.repository_owner }}/s2i-binary
42+
tags: |
43+
type=schedule
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver,pattern=v{{version}}
47+
type=semver,pattern=v{{major}}.{{minor}}
48+
type=semver,pattern=v{{major}}
49+
type=sha
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v1
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v1
54+
- name: Login to DockerHub
55+
if: github.event_name != 'pull_request'
56+
uses: docker/login-action@v1
57+
with:
58+
username: ${{ secrets.DOCKER_HUB_USER }}
59+
password: ${{ secrets.DOCKER_HUB_SECRETS }}
60+
- name: Login to GHCR
61+
if: github.event_name != 'pull_request'
62+
uses: docker/login-action@v1
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.repository_owner }}
66+
password: ${{ secrets.GHCR_TOKEN }}
67+
- name: Build and push Docker images
68+
uses: docker/[email protected]
69+
if: github.repository_owner == 'kubesphere'
70+
with:
71+
context: .
72+
file: Dockerfile
73+
tags: ${{ steps.meta.outputs.tags }}
74+
push: ${{ github.event_name != 'pull_request' }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
platforms: linux/amd64,linux/arm64/v8
77+
- name: Build and push Docker images for Contributors
78+
uses: docker/[email protected]
79+
if: github.repository_owner != 'kubesphere'
80+
with:
81+
context: .
82+
file: Dockerfile
83+
tags: ${{ steps.metaContributors.outputs.tags }}
84+
push: ${{ github.event_name != 'pull_request' }}
85+
labels: ${{ steps.metaContributors.outputs.labels }}
86+
platforms: linux/amd64,linux/arm64/v8

0 commit comments

Comments
 (0)