From abf9c1529d76e6e60f2d2b62b77a2bbba5350d3a Mon Sep 17 00:00:00 2001 From: "wen.rui" Date: Mon, 18 Sep 2023 15:46:05 +0800 Subject: [PATCH] Build admission image during schedule CI --- .github/actions/build-push-for-e2e.yml | 91 +++++++++++++++++++ .../auto-kubean-compatibility-schedule.yaml | 49 +--------- .github/workflows/auto-pr-ci.yaml | 84 +---------------- .github/workflows/e2e_schedule.yaml | 52 +---------- .github/workflows/kubean_e2e_test_ci.yaml | 45 +-------- .github/workflows/os_e2e_schedule.yaml | 53 +---------- 6 files changed, 97 insertions(+), 277 deletions(-) create mode 100644 .github/actions/build-push-for-e2e.yml diff --git a/.github/actions/build-push-for-e2e.yml b/.github/actions/build-push-for-e2e.yml new file mode 100644 index 000000000..042064ca3 --- /dev/null +++ b/.github/actions/build-push-for-e2e.yml @@ -0,0 +1,91 @@ +name: Build and Push e2e images + +on: + workflow_call: + +jobs: + build-push-for-e2e: + needs: [ unit-test,get_ref ] + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + + steps: + - name: Set env + run: | + ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') + echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} + + - name: Echo env + run: | + echo "REPO: ${{ env.REPO }}" + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ needs.get_ref.outputs.ref }} + + - name: Log in to registry + # This is where you will update the PAT to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: kubean-operator Build image + run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME + + - name: kubean-operator Push image + run: | + IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION + + - name: kubean-admission Build image + run: docker build . --file ./build/images/$KUBEAN_ADMISSION_IMAGE_NAME/Dockerfile --tag $KUBEAN_ADMISSION_IMAGE_NAME + + - name: kubean-admission Push image + run: | + IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUBEAN_ADMISSION_IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $KUBEAN_ADMISSION_IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION + + - name: spray-job Build image + run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + + - name: spray-job Push image + run: | + IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION + + - name: airgap-patch Build image + run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + + - name: airgap-patch Push image + run: | + IMAGE_ID=ghcr.io/${{ env.REPO }}/$AIRGAP_PATCH_IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $AIRGAP_PATCH_IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/.github/workflows/auto-kubean-compatibility-schedule.yaml b/.github/workflows/auto-kubean-compatibility-schedule.yaml index 5fc9c645d..bc04f9bc2 100644 --- a/.github/workflows/auto-kubean-compatibility-schedule.yaml +++ b/.github/workflows/auto-kubean-compatibility-schedule.yaml @@ -19,55 +19,8 @@ env: jobs: build-push-for-e2e: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read + uses: kubean-io/kubean/.github/actions/build-push-for-e2e.yml@main - steps: - - name: Set env - run: | - ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') - echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} - - name: Echo env - run: | - echo "REPO: ${{ env.REPO }}" - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: kubean-operator Build image - run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME - - - name: kubean-operator Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - - name: spray-job Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION auto-kubean-compatibility: runs-on: [self-hosted, online] permissions: diff --git a/.github/workflows/auto-pr-ci.yaml b/.github/workflows/auto-pr-ci.yaml index c1e2048dc..c49595dc9 100644 --- a/.github/workflows/auto-pr-ci.yaml +++ b/.github/workflows/auto-pr-ci.yaml @@ -83,89 +83,7 @@ jobs: build-push-for-e2e: needs: [ unit-test,get_ref ] - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - - steps: - - name: Set env - run: | - ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') - echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} - - - name: Echo env - run: | - echo "REPO: ${{ env.REPO }}" - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ needs.get_ref.outputs.ref }} - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: kubean-operator Build image - run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME - - - name: kubean-operator Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - - name: kubean-admission Build image - run: docker build . --file ./build/images/$KUBEAN_ADMISSION_IMAGE_NAME/Dockerfile --tag $KUBEAN_ADMISSION_IMAGE_NAME - - - name: kubean-admission Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUBEAN_ADMISSION_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUBEAN_ADMISSION_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - - name: spray-job Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - - name: airgap-patch Build image - run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - - name: airgap-patch Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$AIRGAP_PATCH_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $AIRGAP_PATCH_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + uses: kubean-io/kubean/.github/actions/build-push-for-e2e.yml@main e2e: needs: [ build-push-for-e2e,get_ref ] diff --git a/.github/workflows/e2e_schedule.yaml b/.github/workflows/e2e_schedule.yaml index cbf264d64..a6cde9e4f 100644 --- a/.github/workflows/e2e_schedule.yaml +++ b/.github/workflows/e2e_schedule.yaml @@ -21,57 +21,7 @@ env: jobs: build-push-for-e2e: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - - steps: - - name: Set env - run: | - ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') - echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} - - - name: Echo env - run: | - echo "REPO: ${{ env.REPO }}" - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: kubean-operator Build image - run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME - - - name: kubean-operator Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - - name: spray-job Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + uses: kubean-io/kubean/.github/actions/build-push-for-e2e.yml@main schedule_sonobouy_e2e: needs: build-push-for-e2e diff --git a/.github/workflows/kubean_e2e_test_ci.yaml b/.github/workflows/kubean_e2e_test_ci.yaml index 0c74b2dba..236404568 100644 --- a/.github/workflows/kubean_e2e_test_ci.yaml +++ b/.github/workflows/kubean_e2e_test_ci.yaml @@ -20,50 +20,7 @@ env: jobs: build-push-for-e2e: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Set env - run: | - ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') - echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} - - name: Echo env - run: | - echo "REPO: ${{ env.REPO }}" - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - name: kubean-operator Build image - run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME - - name: kubean-operator Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - name: spray-job Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + uses: kubean-io/kubean/.github/actions/build-push-for-e2e.yml@main get_helm_version: runs-on: ubuntu-latest diff --git a/.github/workflows/os_e2e_schedule.yaml b/.github/workflows/os_e2e_schedule.yaml index dbdcdaec7..cc2908745 100644 --- a/.github/workflows/os_e2e_schedule.yaml +++ b/.github/workflows/os_e2e_schedule.yaml @@ -9,6 +9,7 @@ on: env: KUKEAN_OPERATOR_IMAGE_NAME: kubean-operator + KUBEAN_ADMISSION_IMAGE_NAME: kubean-admission KUBESPRAY_IMAGE_NAME: kubespray SPRAY_JOB_IMAGE_NAME: spray-job KUBESPRAY_TAG: latest @@ -19,57 +20,7 @@ env: jobs: build-push-for-e2e: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - - steps: - - name: Set env - run: | - ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') - echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} - - - name: Echo env - run: | - echo "REPO: ${{ env.REPO }}" - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: kubean-operator Build image - run: docker build . --file ./build/images/$KUKEAN_OPERATOR_IMAGE_NAME/Dockerfile --tag $KUKEAN_OPERATOR_IMAGE_NAME - - - name: kubean-operator Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$KUKEAN_OPERATOR_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $KUKEAN_OPERATOR_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG - - - name: spray-job Push image - run: | - IMAGE_ID=ghcr.io/${{ env.REPO }}/$SPRAY_JOB_IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - # Strip git ref prefix from version - VERSION="$(git describe --tags --abbrev=8 --dirty)-e2e" - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SPRAY_JOB_IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + uses: kubean-io/kubean/.github/actions/build-push-for-e2e.yml@main schedule_os_e2e: needs: build-push-for-e2e