docs(main): replace lookup env to apply (#3039) #1
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
name: Build Frontend Image | |
on: | |
workflow_dispatch: | |
inputs: | |
push_mage: | |
description: 'Push images' | |
required: false | |
type: boolean | |
push: | |
branches: [ "main" ] | |
paths: | |
- "frontend/providers/**" | |
- ".github/workflows/frontend-providers.yml" | |
- "!**/*.md" | |
- "!**/*.yaml" | |
pull_request: | |
branches: [ "*" ] | |
paths: | |
- "frontend/providers/**" | |
- ".github/workflows/frontend-providers.yml" | |
- "!**/*.md" | |
- "!**/*.yaml" | |
env: | |
# Common versions | |
GO_VERSION: "1.20" | |
DEFAULT_OWNER: "labring" | |
jobs: | |
image-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
module: [ providers/applaunchpad, providers/bytebase, providers/imagehub, providers/terminal,desktop ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Expose git commit data | |
uses: rlespinasse/git-commit-data-action@v1 | |
- name: Prepare | |
id: prepare | |
run: | | |
TAG=${GIT_COMMIT_SHORT_SHA} | |
echo tag_name=${TAG} >> $GITHUB_OUTPUT | |
- name: Extract module name | |
id: module_name | |
run: | | |
MODULE_NAME=$(basename ${{ matrix.module }}) | |
echo "MODULE_NAME=${MODULE_NAME}" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/sealos-${{ env.MODULE_NAME }}-frontend | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=raw,value=dev,enable=true | |
type=raw,value=${{ steps.prepare.outputs.tag_name }},enable=true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Github Container Hub | |
if: ${{ (github.event_name == 'push') || (inputs.push_mage == true) }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GH_PAT }} | |
- name: Build And Push | |
uses: docker/build-push-action@v4 | |
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) }} | |
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) }} | |
needs: | |
- image-build | |
- save-sealos | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
module: [ providers/applaunchpad, providers/bytebase, providers/imagehub, providers/terminal,desktop ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Extract module name | |
id: module_name | |
run: | | |
MODULE_NAME=$(basename ${{ matrix.module }}) | |
echo "MODULE_NAME=${MODULE_NAME}" >> $GITHUB_ENV | |
- name: Expose git commit data | |
uses: rlespinasse/git-commit-data-action@v1 | |
- name: Prepare | |
id: prepare | |
run: | | |
TAG=${GIT_COMMIT_SHORT_SHA} | |
echo tag_name=${TAG} >> $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 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 | |
- 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 | |
run: | | |
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io | |
- name: Build ${{ env.MODULE_NAME }}-frontend cluster image | |
working-directory: frontend/${{ matrix.module }}/deploy | |
run: | | |
sudo sed -i "s;${{ steps.prepare.outputs.old_docker_image }};${{ steps.prepare.outputs.new_docker_image }};" manifests/* | |
sudo sealos build -t ${{ steps.prepare.outputs.cluster_image }}-amd64 --platform linux/amd64 -f Kubefile | |
# delete old registry cache | |
sudo rm -rf registry | |
sudo sealos build -t ${{ steps.prepare.outputs.cluster_image }}-arm64 --platform linux/arm64 -f Kubefile | |
- name: Manifest Cluster Images | |
run: | | |
sudo sealos images | |
bash docker/patch/manifest-cluster-images.sh "sealos-cloud-${{ env.MODULE_NAME }}-frontend" | |
env: | |
OWNER: ${{ github.repository_owner }} | |
- name: Sync Images | |
uses: peter-evans/create-or-update-comment@v1 | |
if: ${{ github.repository_owner == env.DEFAULT_OWNER }} | |
with: | |
issue-number: 251 | |
repository: labring-actions/cluster-image | |
body: | | |
/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ env.MODULE_NAME }}-frontend:${{ steps.prepare.outputs.tag_name }} | |
token: "${{ secrets.GH_PAT }}" |