-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the Service to automatically build a cluster-image. (#4096)
- Loading branch information
Showing
12 changed files
with
113 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,8 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
module: [ hub, database ] | ||
## TODO: add more modules | ||
module: [ database ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -159,102 +160,103 @@ jobs: | |
|
||
save-sealos: | ||
uses: ./.github/workflows/import-save-sealos.yml | ||
# build-cluster-image: | ||
# if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }} | ||
# needs: | ||
# - image-build | ||
# - save-sealos | ||
# runs-on: ubuntu-latest | ||
# strategy: | ||
# matrix: | ||
# module: [ ] | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v3 | ||
# with: | ||
# fetch-depth: 0 | ||
# | ||
# - name: Expose git commit data | ||
# uses: rlespinasse/git-commit-data-action@v1 | ||
# - name: Check if tag | ||
# id: check_tag | ||
# run: | | ||
# if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
# echo "isTag=true" >> "$GITHUB_OUTPUT" | ||
# else | ||
# echo "isTag=false" >> "$GITHUB_OUTPUT" | ||
# fi | ||
# - name: Prepare | ||
# id: prepare | ||
# run: | | ||
# bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}" | ||
# 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 | ||
# | ||
# - name: Download sealos | ||
# uses: actions/download-artifact@v3 | ||
# with: | ||
# name: sealos | ||
# path: /tmp/ | ||
# - name: Verify sealos | ||
# run: | | ||
# sudo chmod a+x /tmp/sealos | ||
# sudo mv /tmp/sealos /usr/bin/sealos | ||
# sudo sealos version | ||
# | ||
# - name: Sealos login to ghcr.io | ||
# # if push to master, then login to ghcr.io | ||
# run: | | ||
# sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io | ||
# | ||
# - name: Mutate image tag in deploy files | ||
# working-directory: service/${{ matrix.module }}/deploy | ||
# run: | | ||
# OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest | ||
# NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
# sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/* | ||
# | ||
# - name: Build ${{ matrix.module }}-service cluster image | ||
# working-directory: service/${{ matrix.module }}/deploy | ||
# run: | | ||
# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile | ||
# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile | ||
# sudo sealos images | ||
# - name: Build ${{ matrix.module }}-service cluster image for latest | ||
# run: | | ||
# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
# CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest | ||
# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 | ||
# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 | ||
# sudo sealos images | ||
# bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST | ||
# - name: Renew issue and Sync Images | ||
# uses: labring/[email protected] | ||
# if: ${{ github.repository_owner == env.DEFAULT_OWNER }} | ||
# with: | ||
# version: v0.0.8-rc1 | ||
# env: | ||
# GH_TOKEN: "${{ secrets.GH_PAT }}" | ||
# SEALOS_TYPE: "issue_renew" | ||
# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" | ||
# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" | ||
# SEALOS_ISSUE_LABEL: "dayly-report" | ||
# SEALOS_ISSUE_TYPE: "day" | ||
# SEALOS_ISSUE_REPO: "labring-actions/cluster-image" | ||
# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}" | ||
# - name: Renew issue and Sync Images for latest | ||
# uses: labring/[email protected] | ||
# if: ${{ github.repository_owner == env.DEFAULT_OWNER }} | ||
# with: | ||
# version: v0.0.8-rc1 | ||
# env: | ||
# GH_TOKEN: "${{ secrets.GH_PAT }}" | ||
# SEALOS_TYPE: "issue_renew" | ||
# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" | ||
# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" | ||
# SEALOS_ISSUE_LABEL: "dayly-report" | ||
# SEALOS_ISSUE_TYPE: "day" | ||
# SEALOS_ISSUE_REPO: "labring-actions/cluster-image" | ||
# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest" | ||
build-cluster-image: | ||
if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }} | ||
needs: | ||
- image-build | ||
- save-sealos | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
## TODO: add more modules | ||
module: [ database ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Expose git commit data | ||
uses: rlespinasse/git-commit-data-action@v1 | ||
- name: Check if tag | ||
id: check_tag | ||
run: | | ||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
echo "isTag=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "isTag=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Prepare | ||
id: prepare | ||
run: | | ||
bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}" | ||
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 | ||
- name: Download sealos | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: sealos | ||
path: /tmp/ | ||
- name: Verify sealos | ||
run: | | ||
sudo chmod a+x /tmp/sealos | ||
sudo mv /tmp/sealos /usr/bin/sealos | ||
sudo sealos version | ||
- name: Sealos login to ghcr.io | ||
# if push to master, then login to ghcr.io | ||
run: | | ||
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io | ||
- name: Mutate image tag in deploy files | ||
working-directory: service/${{ matrix.module }}/deploy | ||
run: | | ||
OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest | ||
NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/* | ||
- name: Build ${{ matrix.module }}-service cluster image | ||
working-directory: service/${{ matrix.module }}/deploy | ||
run: | | ||
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile | ||
sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile | ||
sudo sealos images | ||
- name: Build ${{ matrix.module }}-service cluster image for latest | ||
run: | | ||
CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} | ||
CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest | ||
sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 | ||
sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 | ||
sudo sealos images | ||
bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST | ||
- name: Renew issue and Sync Images | ||
uses: labring/[email protected] | ||
if: ${{ github.repository_owner == env.DEFAULT_OWNER }} | ||
with: | ||
version: v0.0.8-rc1 | ||
env: | ||
GH_TOKEN: "${{ secrets.GH_PAT }}" | ||
SEALOS_TYPE: "issue_renew" | ||
SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" | ||
SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" | ||
SEALOS_ISSUE_LABEL: "dayly-report" | ||
SEALOS_ISSUE_TYPE: "day" | ||
SEALOS_ISSUE_REPO: "labring-actions/cluster-image" | ||
SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}" | ||
- name: Renew issue and Sync Images for latest | ||
uses: labring/[email protected] | ||
if: ${{ github.repository_owner == env.DEFAULT_OWNER }} | ||
with: | ||
version: v0.0.8-rc1 | ||
env: | ||
GH_TOKEN: "${{ secrets.GH_PAT }}" | ||
SEALOS_TYPE: "issue_renew" | ||
SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" | ||
SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" | ||
SEALOS_ISSUE_LABEL: "dayly-report" | ||
SEALOS_ISSUE_TYPE: "day" | ||
SEALOS_ISSUE_REPO: "labring-actions/cluster-image" | ||
SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM scratch | ||
COPY registry registry | ||
COPY manifests manifests | ||
|
||
CMD ["kubectl apply -f manifests/deploy.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.