Skip to content

Commit

Permalink
CI: Switch build dev to release (labring#3062)
Browse files Browse the repository at this point in the history
* switch build dev to release

* fix script

* use tag to release image

* fix tag

* fix tag

* fix tag

* fix tag
  • Loading branch information
lingdie authored May 9, 2023
1 parent 7af5505 commit 6e90dd6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 65 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Build Controllers image
on:
workflow_dispatch:
inputs:
push_mage:
push_image:
description: 'Push images'
required: false
type: boolean
build_dev:
description: 'build dev images'
release_tag:
description: 'Release images'
default: 'dev'
required: false
type: boolean
type: string
push:
branches: [ "main" ]
paths:
Expand Down Expand Up @@ -104,8 +105,9 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
echo docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller >> $GITHUB_OUTPUT
- # Add support for more platforms with QEMU (optional)
Expand All @@ -119,14 +121,14 @@ jobs:

- name: Login to Docker Hub
uses: docker/login-action@v2
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}

- name: build (and publish) ${{ matrix.module }} main image
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
env:
# fork friendly ^^
DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller
Expand Down Expand Up @@ -159,7 +161,7 @@ jobs:
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
build-cluster-image:
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
needs:
- image-build
- save-sealos
Expand All @@ -179,8 +181,9 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-controller >> $GITHUB_OUTPUT
echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller >> $GITHUB_OUTPUT
echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-controller >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -225,15 +228,6 @@ jobs:
env:
OWNER: ${{ github.repository_owner }}

- name: Build Dev Cluster Images
if: ${{ inputs.build_dev == true }}
run: |
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:dev
sudo sealos images
bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME
env:
OWNER: ${{ github.repository_owner }}

- name: Sync Images
uses: peter-evans/create-or-update-comment@v1
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
Expand Down
44 changes: 19 additions & 25 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ name: Build Frontend Image
on:
workflow_dispatch:
inputs:
push_mage:
push_image:
description: 'Push images'
required: false
type: boolean
build_dev:
description: 'build dev images'
release_tag:
description: 'Release images'
default: 'dev'
required: false
type: boolean
type: string
push:
branches: [ "main" ]
paths:
- "frontend/providers/**"
- ".github/workflows/frontend-providers.yml"
- ".github/workflows/frontend.yml"
- "!**/*.md"
- "!**/*.yaml"
pull_request:
branches: [ "*" ]
paths:
- "frontend/providers/**"
- ".github/workflows/frontend-providers.yml"
- ".github/workflows/frontend.yml"
- "!**/*.md"
- "!**/*.yaml"

Expand All @@ -49,8 +50,9 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
- name: Extract module name
id: module_name
run: |
Expand All @@ -75,7 +77,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to Github Container Hub
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -87,14 +89,14 @@ jobs:
with:
context: ./frontend/${{ matrix.module }}
file: ./frontend/${{ matrix.module }}/Dockerfile
# Push if it's a push event or if push_mage is true
push: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
# Push if it's a push event or if push_image is true
push: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
cluster-image-build:
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) || (inputs.build_dev == true)}}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) || (inputs.build_dev == true)}}
needs:
- image-build
- save-sealos
Expand All @@ -119,14 +121,15 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
echo old_docker_repo=ghcr.io/labring/sealos-${{ env.MODULE_NAME }}-frontend >> $GITHUB_OUTPUT
echo old_docker_image=ghcr.io/labring/sealos-${{ env.MODULE_NAME }}-frontend:dev >> $GITHUB_OUTPUT
echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ env.MODULE_NAME }}-frontend >> $GITHUB_OUTPUT
echo new_docker_image=ghcr.io/${{ github.repository_owner }}/sealos-${{ env.MODULE_NAME }}-frontend:${TAG} >> $GITHUB_OUTPUT
echo new_docker_image=ghcr.io/${{ github.repository_owner }}/sealos-${{ env.MODULE_NAME }}-frontend:${tag_name} >> $GITHUB_OUTPUT
echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ env.MODULE_NAME }}-frontend >> $GITHUB_OUTPUT
echo cluster_image=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ env.MODULE_NAME }}-frontend:${TAG} >> $GITHUB_OUTPUT
echo cluster_image=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ env.MODULE_NAME }}-frontend:${tag_name} >> $GITHUB_OUTPUT
- name: Download sealos
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -160,15 +163,6 @@ jobs:
env:
OWNER: ${{ github.repository_owner }}

- name: Build Dev Cluster Images
if: ${{ inputs.build_dev == true }}
run: |
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:dev
sudo sealos images
bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME
env:
OWNER: ${{ github.repository_owner }}

- name: Sync Images
uses: peter-evans/create-or-update-comment@v1
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
Expand Down
34 changes: 14 additions & 20 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ name: Build Services image
on:
workflow_dispatch:
inputs:
push_mage:
push_image:
description: 'Push images'
required: false
type: boolean
build_dev:
description: 'build dev images'
release_tag:
description: 'Release images'
default: 'dev'
required: false
type: boolean
type: string
push:
branches: [ "main" ]
paths:
Expand Down Expand Up @@ -105,8 +106,9 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
echo docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
- # Add support for more platforms with QEMU (optional)
Expand All @@ -120,14 +122,14 @@ jobs:

- name: Login to Docker Hub
uses: docker/login-action@v2
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}

- name: build (and publish) ${{ matrix.module }} main image
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
env:
# fork friendly ^^
DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service
Expand Down Expand Up @@ -160,7 +162,7 @@ jobs:
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
build-cluster-image:
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }}
if: ${{ (github.event_name == 'push') || (inputs.push_image == true) }}
needs:
- image-build
- save-sealos
Expand All @@ -180,8 +182,9 @@ jobs:
- name: Prepare
id: prepare
run: |
TAG=${GIT_COMMIT_SHORT_SHA}
echo tag_name=${TAG} >> $GITHUB_OUTPUT
SHA_TAG=${GIT_COMMIT_SHORT_SHA}
tag_name=$(if [ ${{ inputs.push_image }} ]; then echo "${{ inputs.release_tag }}"; else echo "$SHA_TAG"; fi);
echo tag_name=$tag_name >> $GITHUB_OUTPUT
echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT
echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -225,15 +228,6 @@ jobs:
env:
OWNER: ${{ github.repository_owner }}

- name: Build Dev Cluster Images
if: ${{ inputs.build_dev == true }}
run: |
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:dev
sudo sealos images
bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME
env:
OWNER: ${{ github.repository_owner }}

- name: Sync Images
uses: peter-evans/create-or-update-comment@v1
if: ${{ github.repository_owner == env.DEFAULT_OWNER }}
Expand Down

0 comments on commit 6e90dd6

Please sign in to comment.