Skip to content

A modern and elegant dashboard for network traffic visualization and analysis.

feat: Introduce CI/CD workflows for dev branch hygiene, preview branch creation, and enhanced Docker image tagging for dev branches.

luoleib5443b2b86ae
diff --git a/.github/workflows/dev-preview-branch.yml b/.github/workflows/dev-preview-branch.yml
new file mode 100644
index 0000000..707b815
--- /dev/null
+++ b/.github/workflows/dev-preview-branch.yml
@@ -0,0 +1,71 @@
+name: Create Dev Preview Branch
+
+on:
+ pull_request:
+ types: [closed]
+ branches: [dev]
+
+permissions:
+ contents: write
+ pull-requests: read
+
+jobs:
+ create-preview-branch:
+ if: github.event.pull_request.merged == true
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Derive preview branch name
+ id: derive
+ shell: bash
+ run: |
+ head_ref="${{ github.event.pull_request.head.ref }}"
+ merge_sha="${{ github.event.pull_request.merge_commit_sha }}"
+
+ if [[ -z "${merge_sha}" || "${merge_sha}" == "null" ]]; then
+ echo "::error::Missing merge commit SHA on merged PR."
+ exit 1
+ fi
+
+ suffix="${head_ref}"
+ for prefix in "feat/" "feature/" "fix/" "hotfix/" "bugfix/" "chore/" "refactor/" "dev/"; do
+ if [[ "${suffix}" == "${prefix}"* ]]; then
+ suffix="${suffix#${prefix}}"
+ break
+ fi
+ done
+
+ safe="$(echo "${suffix}" \
+ | tr '[:upper:]' '[:lower:]' \
+ | sed 's#[^a-z0-9._/-]#-#g' \
+ | sed 's#//*#/#g' \
+ | sed 's#^/##; s#/$##')"
+
+ if [[ -z "${safe}" ]]; then
+ safe="preview-${{ github.event.pull_request.number }}"
+ fi
+
+ preview_branch="dev/${safe}"
+ echo "preview_branch=${preview_branch}" >> "$GITHUB_OUTPUT"
+ echo "merge_sha=${merge_sha}" >> "$GITHUB_OUTPUT"
+
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Create or update preview branch
+ shell: bash
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+
+ git fetch --no-tags origin "${{ steps.derive.outputs.merge_sha }}"
+ git checkout --detach "${{ steps.derive.outputs.merge_sha }}"
+
+ git push origin "HEAD:refs/heads/${{ steps.derive.outputs.preview_branch }}" --force
+
+ - name: Summary
+ run: |
+ echo "Created/updated preview branch: \`${{ steps.derive.outputs.preview_branch }}\`" >> "$GITHUB_STEP_SUMMARY"
+ echo "From merge commit: \`${{ steps.derive.outputs.merge_sha }}\`" >> "$GITHUB_STEP_SUMMARY"
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
index 521aaa8..d215a24 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -2,10 +2,10 @@ name: Build and Push Docker Image
on:
push:
- branches: [ main, dev ]
+ branches: [ main, dev, 'dev/**' ]
tags: [ 'v*' ]
pull_request:
- branches: [ main ]
+ branches: [ main, dev ]
workflow_dispatch:
env:
@@ -27,6 +27,20 @@ jobs:
id: pkg
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
+ - name: Derive preview tag for dev/* branches
+ id: preview
+ shell: bash
+ run: |
+ if [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == dev/* ]]; then
+ raw="${GITHUB_REF_NAME#dev/}"
+ safe="$(echo "${raw}" | tr '[:upper:]' '[:lower:]' | sed 's#[^a-z0-9._-]#-#g')"
+ echo "enabled=true" >> "$GITHUB_OUTPUT"
+ echo "tag=dev-${safe}" >> "$GITHUB_OUTPUT"
+ else
+ echo "enabled=false" >> "$GITHUB_OUTPUT"
+ echo "tag=" >> "$GITHUB_OUTPUT"
+ fi
+
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@@ -56,10 +70,11 @@ jobs:
${{ env.DOCKERHUB_IMAGE }}
${{ env.GHCR_IMAGE }}
tags: |
- type=raw,value=latest,enable={{is_default_branch}}
- type=raw,value=${{ steps.pkg.outputs.version }},enable={{is_default_branch}}
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
+ type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
+ type=raw,value=${{ steps.pkg.outputs.version }},enable=${{ github.ref_name == 'main' }}
+ type=raw,value=${{ steps.preview.outputs.tag }},enable=${{ steps.preview.outputs.enabled == 'true' }}
+ type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
+ type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=ref,event=pr
type=sha,prefix=,enable={{is_default_branch}}
type=raw,value=dev,enable=${{ github.ref_name == 'dev' }}
@@ -78,7 +93,7 @@ jobs:
platforms: linux/amd64,linux/arm64
- name: Update Docker Hub description
- if: github.event_name != 'pull_request'
+ if: github.event_name != 'pull_request' && github.ref_name == 'main'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
diff --git a/.github/workflows/ensure-dev-synced-with-main.yml b/.github/workflows/ensure-dev-synced-with-main.yml
new file mode 100644
index 0000000..7cbe947
--- /dev/null
+++ b/.github/workflows/ensure-dev-synced-with-main.yml
@@ -0,0 +1,35 @@
+name: Ensure Dev Is Synced With Main
+
+on:
+ pull_request:
+ branches: [dev]
+ types: [opened, synchronize, reopened, ready_for_review]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ check-dev-sync:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Verify dev contains latest main
+ shell: bash
+ run: |
+ git fetch --no-tags origin main dev
+
+ if git merge-base --is-ancestor origin/main origin/dev; then
+ echo "OK: dev already includes latest main."
+ exit 0
+ fi
+
+ echo "::error::Branch 'dev' is behind 'main'. Merge 'main' into 'dev' before merging this PR."
+ echo "main head: $(git rev-parse --short origin/main)"
+ echo "dev head: $(git rev-parse --short origin/dev)"
+ exit 1
diff --git a/package.json b/package.json
index 35b08d4..82dd6e6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "clash-master",
- "version": "1.0.9",
+ "version": "1.1.0",
"private": true,
"workspaces": [
"apps/*",