From 6f2f27a571e9471b69b74ab5d80d53ee916b0c1f Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:02:20 -0800 Subject: [PATCH 01/10] add fleet and ci --- .../{deploy-main.yml => deploy-main.yml.bak} | 0 ...{docker-build.yml => docker-build.yml.bak} | 0 .github/workflows/pr-ci.yaml | 47 +++++++++++++++++++ .../{test-branch.yml => test-branch.yml.bak} | 0 fleet.yaml | 4 ++ k8s/deployment.yaml | 19 ++++++++ k8s/service.yaml | 12 +++++ 7 files changed, 82 insertions(+) rename .github/workflows/{deploy-main.yml => deploy-main.yml.bak} (100%) rename .github/workflows/{docker-build.yml => docker-build.yml.bak} (100%) create mode 100644 .github/workflows/pr-ci.yaml rename .github/workflows/{test-branch.yml => test-branch.yml.bak} (100%) create mode 100644 fleet.yaml create mode 100644 k8s/deployment.yaml create mode 100644 k8s/service.yaml diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml.bak similarity index 100% rename from .github/workflows/deploy-main.yml rename to .github/workflows/deploy-main.yml.bak diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml.bak similarity index 100% rename from .github/workflows/docker-build.yml rename to .github/workflows/docker-build.yml.bak diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml new file mode 100644 index 0000000..f94b312 --- /dev/null +++ b/.github/workflows/pr-ci.yaml @@ -0,0 +1,47 @@ +name: PR Build & Deploy to k3d via Fleet + +on: + pull_request: + branches: [ main ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: lzhengqc/visualsubnetcalc + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: lzhengqc + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build & Push Docker image + run: | + TAG=pr-${{ github.event.pull_request.number }} + docker build -t ghcr.io/lzhengqc/visualsubnetcalc:$TAG . + docker push ghcr.io/lzhengqc/visualsubnetcalc:$TAG + echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV + + - name: Update Kubernetes manifest + run: | + sed -i "s|image: .*|image: ghcr.io/lzhengqc/visualsubnetcalc:${IMAGE_TAG}|g" k8s/deployment.yaml + + - name: Commit GitOps change + run: | + git config user.name "github-actions" + git config user.email "actions@github.com" + git add k8s/deployment.yaml + git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" + git push \ No newline at end of file diff --git a/.github/workflows/test-branch.yml b/.github/workflows/test-branch.yml.bak similarity index 100% rename from .github/workflows/test-branch.yml rename to .github/workflows/test-branch.yml.bak diff --git a/fleet.yaml b/fleet.yaml new file mode 100644 index 0000000..faf8964 --- /dev/null +++ b/fleet.yaml @@ -0,0 +1,4 @@ +namespace: default + +kustomize: + dir: k8s \ No newline at end of file diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000..6606eed --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: visualsubnetcalc +spec: + replicas: 1 + selector: + matchLabels: + app: visualsubnetcalc + template: + metadata: + labels: + app: visualsubnetcalc + spec: + containers: + - name: visualsubnetcalc + image: ghcr.io/lzhengqc/visualsubnetcalc:latest + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 0000000..69cdf6f --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: visualsubnetcalc +spec: + type: ClusterIP + selector: + app: visualsubnetcalc + ports: + - name: http + port: 80 + targetPort: 8080 \ No newline at end of file From 53730250efc0b65a12522cb31c31168c3874eb02 Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:16:17 -0800 Subject: [PATCH 02/10] test pr --- .github/workflows/pr-ci.yaml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml index f94b312..c80be41 100644 --- a/.github/workflows/pr-ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -44,4 +44,4 @@ jobs: git config user.email "actions@github.com" git add k8s/deployment.yaml git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" - git push \ No newline at end of file + git push diff --git a/README.md b/README.md index 7ffc816..77bca3a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Visual Subnet Calculator - [visualsubnetcalc.com](https://visualsubnetcalc.com) - +tst1 ![demo.gif](src%2Fdemo.gif) Visual Subnet Calculator is a modernized tool based on the original work by [davidc](https://github.com/davidc/subnets). From 424c0295e83a30341e60007e52cdc090d4a8641f Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:23:04 -0800 Subject: [PATCH 03/10] update pr ci --- .github/workflows/pr-ci.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml index c80be41..9298c87 100644 --- a/.github/workflows/pr-ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -42,6 +42,10 @@ jobs: run: | git config user.name "github-actions" git config user.email "actions@github.com" + git add k8s/deployment.yaml - git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" - git push + git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" || echo "No changes to commit" + + git push origin HEAD:${{ github.head_ref }} + + From 4071cbc35a56920b54aff3bbd470121324e99b34 Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:26:04 -0800 Subject: [PATCH 04/10] one more --- .github/workflows/pr-ci.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml index 9298c87..9459548 100644 --- a/.github/workflows/pr-ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -43,9 +43,16 @@ jobs: git config user.name "github-actions" git config user.email "actions@github.com" + # Fetch the real PR branch + git fetch origin ${{ github.head_ref }} + + # Rebase CI changes on top of PR branch + git checkout -B ci-temp HEAD + git rebase origin/${{ github.head_ref }} + git add k8s/deployment.yaml git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" || echo "No changes to commit" - git push origin HEAD:${{ github.head_ref }} - + # Push safely back to PR branch + git push origin HEAD:${{ github.head_ref }} --force-with-lease From dad214f0602eb50a3f3fdd9261b36e52b11707d7 Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:33:06 -0800 Subject: [PATCH 05/10] ci only --- .github/workflows/pr-ci.yaml | 41 +++++------------------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml index 9459548..bd6009e 100644 --- a/.github/workflows/pr-ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -1,24 +1,17 @@ -name: PR Build & Deploy to k3d via Fleet +name: PR Build Image on: pull_request: branches: [ main ] -env: - REGISTRY: ghcr.io - IMAGE_NAME: lzhengqc/visualsubnetcalc - jobs: - build-and-deploy: + build: runs-on: ubuntu-latest - permissions: - contents: write packages: write steps: - - name: Checkout repo - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Login to GHCR uses: docker/login-action@v3 @@ -27,32 +20,8 @@ jobs: username: lzhengqc password: ${{ secrets.GITHUB_TOKEN }} - - name: Build & Push Docker image + - name: Build & Push PR image run: | TAG=pr-${{ github.event.pull_request.number }} docker build -t ghcr.io/lzhengqc/visualsubnetcalc:$TAG . - docker push ghcr.io/lzhengqc/visualsubnetcalc:$TAG - echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV - - - name: Update Kubernetes manifest - run: | - sed -i "s|image: .*|image: ghcr.io/lzhengqc/visualsubnetcalc:${IMAGE_TAG}|g" k8s/deployment.yaml - - - name: Commit GitOps change - run: | - git config user.name "github-actions" - git config user.email "actions@github.com" - - # Fetch the real PR branch - git fetch origin ${{ github.head_ref }} - - # Rebase CI changes on top of PR branch - git checkout -B ci-temp HEAD - git rebase origin/${{ github.head_ref }} - - git add k8s/deployment.yaml - git commit -m "ci: deploy PR #${{ github.event.pull_request.number }}" || echo "No changes to commit" - - # Push safely back to PR branch - git push origin HEAD:${{ github.head_ref }} --force-with-lease - + docker push ghcr.io/lzhengqc/visualsubnetcalc:$TAG \ No newline at end of file From 4371811b66f55c5f8497e33ffa0cf9b83a981bba Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:39:08 -0800 Subject: [PATCH 06/10] add more --- .github/workflows/merge-deploy.yaml | 42 +++++++++++++++++++++++++++++ fleet.yaml | 4 --- k8s/deployment.yaml | 19 ------------- k8s/service.yaml | 12 --------- 4 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/merge-deploy.yaml delete mode 100644 fleet.yaml delete mode 100644 k8s/deployment.yaml delete mode 100644 k8s/service.yaml diff --git a/.github/workflows/merge-deploy.yaml b/.github/workflows/merge-deploy.yaml new file mode 100644 index 0000000..04d125b --- /dev/null +++ b/.github/workflows/merge-deploy.yaml @@ -0,0 +1,42 @@ +name: Deploy on Merge to Main + +on: + push: + branches: [ main ] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout app repo + uses: actions/checkout@v4 + + - name: Set image tag + run: | + TAG=$(git rev-parse --short HEAD) + echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV + + - name: Build & Push Release Image + uses: docker/build-push-action@v5 + with: + push: true + tags: ghcr.io/lzhengqc/visualsubnetcalc:${{ env.IMAGE_TAG }} + + - name: Checkout GitOps repo + uses: actions/checkout@v4 + with: + repository: lzhengqc/visualsubnetcalc-gitops + token: ${{ secrets.GITOPS_TOKEN }} + path: gitops + + - name: Update GitOps deployment + run: | + sed -i "s|image: .*|image: ghcr.io/lzhengqc/visualsubnetcalc:${IMAGE_TAG}|g" \ + gitops/k8s/deployment.yaml + + cd gitops + git config user.name "github-actions" + git config user.email "actions@github.com" + git commit -am "deploy: visualsubnetcalc ${IMAGE_TAG}" + git push \ No newline at end of file diff --git a/fleet.yaml b/fleet.yaml deleted file mode 100644 index faf8964..0000000 --- a/fleet.yaml +++ /dev/null @@ -1,4 +0,0 @@ -namespace: default - -kustomize: - dir: k8s \ No newline at end of file diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml deleted file mode 100644 index 6606eed..0000000 --- a/k8s/deployment.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: visualsubnetcalc -spec: - replicas: 1 - selector: - matchLabels: - app: visualsubnetcalc - template: - metadata: - labels: - app: visualsubnetcalc - spec: - containers: - - name: visualsubnetcalc - image: ghcr.io/lzhengqc/visualsubnetcalc:latest - ports: - - containerPort: 8080 \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml deleted file mode 100644 index 69cdf6f..0000000 --- a/k8s/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: visualsubnetcalc -spec: - type: ClusterIP - selector: - app: visualsubnetcalc - ports: - - name: http - port: 80 - targetPort: 8080 \ No newline at end of file From d6676d5a9f50350273313eef1645f3c4ef61cae2 Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:48:37 -0800 Subject: [PATCH 07/10] add latest tag --- .github/workflows/pr-ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-ci.yaml b/.github/workflows/pr-ci.yaml index bd6009e..ff31a56 100644 --- a/.github/workflows/pr-ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -24,4 +24,7 @@ jobs: run: | TAG=pr-${{ github.event.pull_request.number }} docker build -t ghcr.io/lzhengqc/visualsubnetcalc:$TAG . + # add latest tag for testing purpose + docker tag ghcr.io/lzhengqc/visualsubnetcalc:$TAG ghcr.io/lzhengqc/visualsubnetcalc:latest + docker push ghcr.io/lzhengqc/visualsubnetcalc:latest docker push ghcr.io/lzhengqc/visualsubnetcalc:$TAG \ No newline at end of file From 03acf7c13063f1a83fdbca85debf2f83cc4c26f5 Mon Sep 17 00:00:00 2001 From: lzhengqc Date: Sun, 1 Feb 2026 18:54:51 -0800 Subject: [PATCH 08/10] enabled persist state --- dist/index.html | 5 +++ dist/js/main.js | 112 +++++++++++++++++++++++++++++++++++++++++++++++- server.js | 54 +++++++++++++++++++++++ 3 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 server.js diff --git a/dist/index.html b/dist/index.html index 401293e..42464b1 100644 --- a/dist/index.html +++ b/dist/index.html @@ -99,6 +99,8 @@

Visual Subnet Calculator

+ +
+ + +