Skip to content

Commit

Permalink
ci: refactor CI/CD flows for images (#123)
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo authored Nov 15, 2023
1 parent 14922bd commit 6ff5ff4
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ jobs:
packages: write

strategy:
max-parallel: 1
matrix:
module: [builder-go, builder-others]
go-profile: [go-1.21, go-1.20, go-1.19]
builder-profile: [local-docker]
platform: [linux/amd64, linux/arm64]
# go-profile: [go-1.21, go-1.20, go-1.19]
# module: [builder-go, builder-others]
go-profile: [go-1.21]
module: [builder-go]
exclude:
- module: builder-others
go-profile: go-1.20
Expand Down Expand Up @@ -65,17 +64,17 @@ jobs:
path: "~/.skaffold/cache"
key: skaffold/${{ matrix.platform }}/cd/${{ matrix.module }}/${{ matrix.go-profile }}-${{ github.sha }}
restore-keys: |
skaffold/${{ matrix.platform }}/cd/${{ matrix.module }}/${{ matrix.go-profile }}-${{ github.sha }}
skaffold/${{ matrix.platform }}/cd/${{ matrix.module }}/${{ matrix.go-profile }}-
skaffold/${{ matrix.platform }}/cd/${{ matrix.module }}/
- name: Build images
working-directory: dockerfiles/cd
run: |
skaffold build \
--push=false \
--build-concurrency 1 \
--platform ${{ matrix.platform }} \
--cache-artifacts \
--default-repo ghcr.io/pingcap-qe/cd/builders \
--module ${{ matrix.module }} \
--platform ${{ matrix.platform }} \
--profile ${{ matrix.go-profile }},${{ matrix.builder-profile }} \
--default-repo ghcr.io/pingcap-qe/cd/builders
--push=false
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ jobs:
packages: write

strategy:
max-parallel: 1
matrix:
go-profile: [go-1.21, go-1.20, go-1.19]
builder-profile: [local-docker]
module: [base, release-utils]
platform: [linux/amd64, linux/arm64]

builder-profile: [local-docker]
go-profile: [go-1.21, go-1.20, go-1.19]
exclude:
- module: release-utils
go-profile: go-1.20
- module: release-utils
go-profile: go-1.19
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -55,19 +61,20 @@ jobs:
uses: actions/cache@v3
with:
path: "~/.skaffold/cache"
key: skaffold/${{ matrix.platform }}/ci-base-${{ matrix.go-profile }}-${{ github.sha }}
key: skaffold/${{ matrix.platform }}/ci/${{ matrix.module }}/${{ matrix.go-profile }}-${{ github.sha }}
restore-keys: |
skaffold/${{ matrix.platform }}/ci-base-${{ matrix.go-profile }}-${{ github.sha }}
skaffold/${{ matrix.platform }}/ci-base-${{ matrix.go-profile }}-
skaffold/${{ matrix.platform }}/ci-base-
skaffold/${{ matrix.platform }}/ci/${{ matrix.module }}/${{ matrix.go-profile }}-
skaffold/${{ matrix.platform }}/ci/${{ matrix.module }}/
skaffold/${{ matrix.platform }}/ci/
- name: Build images
working-directory: dockerfiles/ci
run: |
skaffold build \
--build-concurrency 1 \
--cache-artifacts \
--push=false \
--default-repo ghcr.io/pingcap-qe/ci \
--module ${{ matrix.module }} \
--platform ${{ matrix.platform }} \
--module base \
--profile ${{ matrix.go-profile }},${{ matrix.builder-profile }} \
--default-repo ghcr.io/pingcap-qe/ci
--push=false
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
packages: write

strategy:
max-parallel: 1
matrix:
builder-profile: [local-docker]
platform: [linux/amd64, linux/arm64]
Expand Down Expand Up @@ -56,16 +57,15 @@ jobs:
path: "~/.skaffold/cache"
key: skaffold/${{ matrix.platform }}/prod-bases-${{ github.sha }}
restore-keys: |
skaffold/${{ matrix.platform }}/prod-bases-${{ github.sha }}
skaffold/${{ matrix.platform }}/prod-bases-
- name: Build images
working-directory: dockerfiles/bases
run: |
skaffold build \
--build-concurrency 1 \
--cache-artifacts \
--push=false \
--default-repo ghcr.io/pingcap-qe/bases \
--platform ${{ matrix.platform }} \
--profile ${{ matrix.builder-profile }} \
--default-repo ghcr.io/pingcap-qe/bases
--push=false
74 changes: 74 additions & 0 deletions .github/workflows/release-cd-builder-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Publish CD builder images
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "dockerfiles/cd/**/Dockerfile"
- "dockerfiles/cd/**/*.Dockerfile"
- "dockerfiles/cd/skaffold.yaml"

jobs:
skaffold:
name: publish images with skaffold
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
max-parallel: 1
matrix:
module: [builder-go, builder-others]
go-profile: [go-1.21, go-1.20, go-1.19]
builder-profile: [local-docker]
exclude:
- module: builder-others
go-profile: go-1.20
- module: builder-others
go-profile: go-1.19

steps:
- name: Checkout sources
uses: actions/checkout@v4

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.8.0/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Cache layers
uses: actions/cache@v3
with:
path: "~/.skaffold/cache"
key: skaffold/cd/${{ matrix.module }}/${{ matrix.go-profile }}-${{ github.sha }}
restore-keys: |
skaffold/cd/${{ matrix.module }}/${{ matrix.go-profile }}-
skaffold/cd/${{ matrix.module }}/
- name: Publish images
working-directory: dockerfiles/cd
run: |
skaffold build \
--build-concurrency 1 \
--cache-artifacts \
--default-repo ghcr.io/pingcap-qe/cd/builders \
--module ${{ matrix.module }} \
--profile ${{ matrix.go-profile }},${{ matrix.builder-profile }}
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
name: Pull test for CI utils images
name: Publish CI base images
on:
pull_request:
workflow_dispatch:
push:
branches:
- main
paths:
- "dockerfiles/ci/release-utils/**/Dockerfile"
- "dockerfiles/ci/release-utils/**/*.Dockerfile"
- "dockerfiles/ci/base/**/Dockerfile"
- "dockerfiles/ci/base/**/*.Dockerfile"
- "dockerfiles/ci/skaffold.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
skaffold:
name: build images with skaffold
name: publish images with skaffold
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
max-parallel: 1
matrix:
module: [base, release-utils]
builder-profile: [local-docker]
platform: [linux/amd64, linux/arm64]

go-profile: [go-1.21, go-1.20, go-1.19]
exclude:
- module: release-utils
go-profile: go-1.20
- module: release-utils
go-profile: go-1.19
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,18 +57,18 @@ jobs:
uses: actions/cache@v3
with:
path: "~/.skaffold/cache"
key: skaffold/${{ matrix.platform }}/release-utils-${{ github.sha }}
key: skaffold/ci/${{ matrix.module }}/${{ matrix.go-profile }}-${{ github.sha }}
restore-keys: |
skaffold/${{ matrix.platform }}/release-utils-${{ github.sha }}
skaffold/${{ matrix.platform }}/release-utils-
skaffold/ci/${{ matrix.module }}/${{ matrix.go-profile }}-
skaffold/ci/${{ matrix.module }}/
skaffold/ci/
- name: Build images
- name: Publish images
working-directory: dockerfiles/ci
run: |
skaffold build \
--build-concurrency 1 \
--cache-artifacts \
--push=false \
--platform ${{ matrix.platform }} \
--module release-utils \
--profile ${{ matrix.builder-profile }} \
--default-repo ghcr.io/pingcap-qe/ci
--default-repo ghcr.io/pingcap-qe/ci \
--module ${{ matrix.module }} \
--profile ${{ matrix.go-profile }},${{ matrix.builder-profile }}
65 changes: 65 additions & 0 deletions .github/workflows/release-prod-runtime-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release product base images
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "dockerfiles/bases/**/Dockerfile"
- "dockerfiles/bases/**/*.Dockerfile"
- "dockerfiles/bases/skaffold.yaml"

jobs:
skaffold:
name: publish images with skaffold
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
max-parallel: 1
matrix:
builder-profile: [local-docker]

steps:
- name: Checkout sources
uses: actions/checkout@v4

# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.8.0/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Cache layers
uses: actions/cache@v3
with:
path: "~/.skaffold/cache"
key: skaffold/prod-bases-${{ github.sha }}
restore-keys: |
skaffold/prod-bases-
- name: Publish images
working-directory: dockerfiles/bases
run: |
skaffold build \
--build-concurrency 1 \
--cache-artifacts \
--default-repo ghcr.io/pingcap-qe/bases \
--profile ${{ matrix.builder-profile }}
Loading

0 comments on commit 6ff5ff4

Please sign in to comment.