Skip to content

Commit 485ac87

Browse files
authored
Merge pull request #88 from ErikJiang/update_spray_img_ci
Integrate image build ci
2 parents e4d6fc3 + 902e23e commit 485ac87

File tree

7 files changed

+117
-97
lines changed

7 files changed

+117
-97
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<!--
22
33
Thanks for sending a pull request! Here are some tips for you:
4-
# todo
4+
5+
* make sure your commit is signed off
56
67
-->
78

89
**What type of PR is this?**
9-
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
10-
>
11-
> /kind api-change
12-
> /kind bug
13-
> /kind cleanup
14-
> /kind design
15-
> /kind documentation
16-
> /kind failing-test
17-
> /kind feature
18-
> /kind flake
10+
<!--
11+
Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
12+
13+
/kind api-change
14+
/kind bug
15+
/kind cleanup
16+
/kind design
17+
/kind documentation
18+
/kind failing-test
19+
/kind feature
20+
/kind flake
21+
-->
1922

2023
**What this PR does / why we need it**:
2124

@@ -29,4 +32,3 @@ Fixes #
2932

3033
**Special notes for your reviewer**:
3134

32-
**make sure your commit is signed off**

.github/workflows/tag.yaml renamed to .github/workflows/auto-version-release.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,36 @@ on:
44
push:
55
tags:
66
- 'v[0-9]+.[0-9]+.[0-9]+'
7-
env:
8-
KUKEAN_OPERATOR_IMAGE_NAME: kubean-operator
9-
KUBESPRAY_IMAGE_NAME: kubespray
10-
SPRAY_JOB_IMAGE_NAME: spray-job
11-
KUBESPRAY_TAG: master
7+
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
128

139
jobs:
10+
get-spray-ref:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
sha: ${{ steps.get_ref.outputs.sha }}
14+
steps:
15+
- name: Get kubespray latest commit sha
16+
id: get_ref
17+
run: |
18+
COMMIT_SHA=`git ls-remote https://github.com/kubernetes-sigs/kubespray.git HEAD | awk '{ print $1}'`
19+
echo ::set-output name=sha::${COMMIT_SHA}
20+
1421
call-offline-build:
1522
uses: ./.github/workflows/call-offline-build.yaml
23+
needs: get-spray-ref
24+
with:
25+
spray_ref: ${{ needs.get-spray-ref.outputs.sha }}
1626

17-
call-os-pkgs-build:
18-
uses: ./.github/workflows/call-os-pkgs-build.yaml
19-
2027
call-images-build:
2128
uses: ./.github/workflows/call-images-build.yaml
2229
secrets: inherit
30+
needs: get-spray-ref
31+
with:
32+
spray_ref: ${{ needs.get-spray-ref.outputs.sha }}
33+
34+
call-os-pkgs-build:
35+
uses: ./.github/workflows/call-os-pkgs-build.yaml
36+
2337

2438
charts:
2539
needs: [call-images-build,call-offline-build]
Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: build-image
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
inputs:
6+
spray_ref:
7+
required: true
8+
type: string
49

510
env:
6-
KUKEAN_OPERATOR_IMAGE_NAME: kubean-operator
7-
SPRAY_JOB_IMAGE_NAME: spray-job
8-
KUBESPRAY_TAG: master
11+
ONLINE_REGISTER: ghcr.io
12+
BUILD_PLATFORM: linux/amd64,linux/arm64
913

1014
jobs:
1115
build-push:
@@ -15,44 +19,64 @@ jobs:
1519
contents: read
1620

1721
steps:
22+
- name: Set env
23+
run: |
24+
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
25+
echo "SPRAY_SHA_SHORT=$(echo ${{ inputs.spray_ref }} | cut -c 1-7)" >> ${GITHUB_ENV}
26+
27+
- name: Echo env
28+
run: |
29+
echo "REPO: ${{ env.REPO }}"
30+
echo "SPRAY_SHA_SHORT: ${{ env.SPRAY_SHA_SHORT }}"
31+
1832
- uses: actions/checkout@v3
1933
with:
2034
fetch-depth: 0
2135

36+
- uses: actions/checkout@v3
37+
with:
38+
repository: kubernetes-sigs/kubespray
39+
ref: ${{ inputs.spray_ref }}
40+
path: ./kubespray
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v2
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/[email protected]
47+
2248
- name: Log in to registry
23-
# This is where you will update the PAT to GITHUB_TOKEN
2449
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
2550

26-
- name: kubean-operator Build image
27-
run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME
51+
- name: kubespray base image build
52+
uses: docker/[email protected]
53+
with:
54+
context: ./
55+
file: ./build/images/kubespray/Dockerfile
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
57+
push: true
58+
platforms: ${{ env.BUILD_PLATFORM }}
59+
tags: ${{ env.ONLINE_REGISTER }}/${{ env.REPO }}/kubespray:${{ env.SPRAY_SHA_SHORT }}
2860

29-
- name: kubean-operator Push image
30-
run: |
31-
IMAGE_ID=ghcr.io/${{ github.repository }}/$KUKEAN_OPERATOR_IMAGE_NAME
32-
# Change all uppercase to lowercase
33-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
34-
# Strip git ref prefix from version
35-
VERSION=$(git describe --tags --abbrev=8 --dirty)
36-
echo IMAGE_ID=$IMAGE_ID
37-
echo VERSION=$VERSION
38-
docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION
39-
docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:latest
40-
docker push $IMAGE_ID:$VERSION
41-
docker push $IMAGE_ID:latest
42-
43-
- name: spray-job Build image
44-
run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg spray_tag=$KUBESPRAY_TAG
45-
46-
- name: spray-job Push image
47-
run: |
48-
IMAGE_ID=ghcr.io/${{ github.repository }}/$SPRAY_JOB_IMAGE_NAME
49-
# Change all uppercase to lowercase
50-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
51-
# Strip git ref prefix from version
52-
VERSION=$(git describe --tags --abbrev=8 --dirty)
53-
echo IMAGE_ID=$IMAGE_ID
54-
echo VERSION=$VERSION
55-
docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION
56-
docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:latest
57-
docker push $IMAGE_ID:$VERSION
58-
docker push $IMAGE_ID:latest
61+
- name: spray-job image build
62+
uses: docker/[email protected]
63+
with:
64+
context: ./
65+
file: ./build/images/spray-job/Dockerfile
66+
github-token: ${{ secrets.GITHUB_TOKEN }}
67+
push: true
68+
platforms: ${{ env.BUILD_PLATFORM }}
69+
tags: ${{ env.ONLINE_REGISTER }}/${{ env.REPO }}/spray-job:${{ github.ref_name }}
70+
build-args: |
71+
SPRAY_TAG=${{ env.SPRAY_SHA_SHORT }}
72+
REPO=${{ env.REPO }}
73+
74+
- name: kubean-operator image build
75+
uses: docker/[email protected]
76+
with:
77+
context: ./
78+
file: ./build/images/kubean-operator/Dockerfile
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
80+
push: true
81+
platforms: ${{ env.BUILD_PLATFORM }}
82+
tags: ${{ env.ONLINE_REGISTER }}/${{ env.REPO }}/kubean-operator:${{ github.ref_name }}

.github/workflows/call-offline-build.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
name: Offline Build CI
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
inputs:
6+
spray_ref:
7+
required: true
8+
type: string
49

510
jobs:
611
offline-build:
712
runs-on: ubuntu-latest
813
steps:
14+
- name: Set env
15+
run: echo "SPRAY_SHA_SHORT=$(echo ${{ inputs.spray_ref }} | cut -c 1-7)" >> ${GITHUB_ENV}
16+
17+
- name: Echo env
18+
run: echo ${SPRAY_SHA_SHORT}
19+
920
- name: git clone kubean repo
1021
uses: actions/checkout@v3
1122
with:
@@ -15,16 +26,16 @@ jobs:
1526
uses: actions/checkout@v3
1627
with:
1728
repository: kubernetes-sigs/kubespray
18-
ref: ${{ env.KUBESPRAY_TAG }}
29+
ref: ${{ inputs.spray_ref }}
1930
path: ./kubespray
2031

2132
- name: install yq tool
2233
uses: mikefarah/[email protected]
2334

2435
- name: generate ComponentsVersion & OfflineVersion files
2536
run: |
26-
KUBEAN_TAG=${GITHUB_REF_NAME} KUBESPRAY_TAG=${{ env.KUBESPRAY_TAG }} bash artifacts/manage_version_cr.sh create_componentsversion
27-
KUBEAN_TAG=${GITHUB_REF_NAME} KUBESPRAY_TAG=${{ env.KUBESPRAY_TAG }} bash artifacts/manage_version_cr.sh create_offlineversion
37+
KUBEAN_TAG=${GITHUB_REF_NAME} KUBESPRAY_TAG=${SPRAY_SHA_SHORT} bash artifacts/manage_version_cr.sh create_componentsversion
38+
KUBEAN_TAG=${GITHUB_REF_NAME} KUBESPRAY_TAG=${SPRAY_SHA_SHORT} bash artifacts/manage_version_cr.sh create_offlineversion
2839
- name: preparing the python environment
2940
uses: actions/setup-python@v4
3041
with:

.github/workflows/call-os-pkgs-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: docker/setup-qemu-action@v2
2424

2525
- name: Set up Docker Buildx
26-
uses: docker/setup-buildx-action@v1
26+
uses: docker/setup-buildx-action@v2.0.0
2727

2828
- name: Build OS packages to local
2929
uses: docker/build-push-action@v3

.github/workflows/spray-image-build.yaml

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

build/images/spray-job/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
ARG spray_tag=master
2-
FROM ghcr.io/kubean-io/kubean/kubespray:$spray_tag
1+
ARG SPRAY_TAG=master
2+
ARG REPO=kubean-io/kubean
3+
4+
FROM ghcr.io/${REPO}/kubespray:${SPRAY_TAG}
35

46
WORKDIR /kubespray
57

0 commit comments

Comments
 (0)