Skip to content

Commit

Permalink
ci: use matrix and cache to speed up the build (koordinator-sh#282)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Liu <[email protected]>
  • Loading branch information
jasonliu747 authored Jun 21, 2022
1 parent 1caf1cd commit c4e2272
Showing 1 changed file with 14 additions and 39 deletions.
53 changes: 14 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ jobs:

build-and-push:
needs: [golangci-lint, staticcheck, unit-tests]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [koordlet, koord-manager, koord-scheduler]
env:
GITHUB_REG: ghcr.io
ALIYUN_REG: registry.cn-beijing.aliyuncs.com
if: github.ref == 'refs/heads/main'
steps:
- uses: docker/setup-buildx-action@v2
- name: Login to GHCR
Expand All @@ -105,53 +109,24 @@ jobs:
uses: docker/login-action@v2
with:
registry: ${{ env.ALIYUN_REG }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PWD }}
- name: Build koord-manager and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
push: true
pull: true
build-args: |
MODULE=koord-manager
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at}}
org.opencontainers.image.licenses=Apache-2.0
tags: |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/koord-manager:latest
${{ env.ALIYUN_REG }}/${{ github.repository_owner }}/koord-manager:latest
- name: Build koord-scheduler and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
push: true
pull: true
build-args: |
MODULE=koord-scheduler
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at}}
org.opencontainers.image.licenses=Apache-2.0
tags: |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/koord-scheduler:latest
${{ env.ALIYUN_REG }}/${{ github.repository_owner }}/koord-scheduler:latest
- name: Build koordlet and push
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PWD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
push: true
pull: true
build-args: |
MODULE=koordlet
MODULE=${{ matrix.target }}
labels: |
org.opencontainers.image.title=${{ matrix.target }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at}}
org.opencontainers.image.licenses=Apache-2.0
tags: |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/koordlet:latest
${{ env.ALIYUN_REG }}/${{ github.repository_owner }}/koordlet:latest
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:latest
${{ env.ALIYUN_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:latest
cache-from: type=gha,scope=build-${{ matrix.target }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.target }}

0 comments on commit c4e2272

Please sign in to comment.