Skip to content

Commit

Permalink
Merge pull request #3 from LinuxSuRen/test-github-action
Browse files Browse the repository at this point in the history
Using GitHub action to build multi-arch image
  • Loading branch information
ks-ci-bot authored May 27, 2021
2 parents d776840 + 17c2dee commit e7a8e0f
Showing 1 changed file with 157 additions and 0 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Build
# Need GitHub secret: DOCKER_HUB_USER, DOCKER_HUB_SECRETS, GHCR_TOKEN

on:
push:
branches:
- master
- test-* # make it be easier for contributors to test
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'

jobs:
BuildCore:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Docker meta for kubesphere
id: meta
if: github.repository_owner == 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
kubespheredev/s2i-core-centos7
ghcr.io/${{ github.repository_owner }}/s2i-core-centos7
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Docker meta for Contributors
id: metaContributors
if: github.repository_owner != 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/${{ github.repository_owner }}/s2i-core-centos7
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_SECRETS }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2.4.0
if: github.repository_owner == 'kubesphere'
with:
context: core
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
- name: Build and push Docker images for Contributors
uses: docker/build-push-action@v2.4.0
if: github.repository_owner != 'kubesphere'
with:
context: core
tags: ${{ steps.metaContributors.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.metaContributors.outputs.labels }}
platforms: linux/amd64,linux/arm64

BuildBase:
runs-on: ubuntu-20.04
needs: BuildCore
steps:
- uses: actions/checkout@v2
- name: Docker meta for kubesphere
id: meta
if: github.repository_owner == 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
kubespheredev/s2i-base-centos7
ghcr.io/${{ github.repository_owner }}/s2i-base-centos7
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Docker meta for Contributors
id: metaContributors
if: github.repository_owner != 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/${{ github.repository_owner }}/s2i-base-centos7
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_SECRETS }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2.4.0
if: github.repository_owner == 'kubesphere'
with:
context: base
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
- name: Build and push Docker images for Contributors
uses: docker/build-push-action@v2.4.0
if: github.repository_owner != 'kubesphere'
with:
context: base
tags: ${{ steps.metaContributors.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.metaContributors.outputs.labels }}
platforms: linux/amd64,linux/arm64

0 comments on commit e7a8e0f

Please sign in to comment.