Просмотр исходного кода

Merge pull request #13667 from id/20240822-add-manual-workflow-to-update-dashboard-version

ci: add manual workflow to update dashboard version
Ivan Dyachkov 1 год назад
Родитель
Сommit
583bbf62bc
1 измененных файлов с 62 добавлено и 0 удалено
  1. 62 0
      .github/workflows/bump-dashboard-version.yaml

+ 62 - 0
.github/workflows/bump-dashboard-version.yaml

@@ -0,0 +1,62 @@
+name: Bump Dashboard Version
+
+concurrency:
+  group: bump-dashboard-version-${{ github.event_name }}-${{ github.ref }}
+  cancel-in-progress: true
+
+on:
+  workflow_dispatch:
+    inputs:
+      emqx-name:
+        required: true
+        type: choice
+        default: emqx
+        options:
+        - emqx
+        - emqx-enterprise
+      version:
+        description: 'Dashboard version'
+        type: string
+        required: true
+
+permissions:
+  contents: read
+
+jobs:
+  bump-dashboard-version:
+    runs-on: ubuntu-latest
+    env:
+      EMQX_NAME: ${{ github.event.inputs.emqx-name }}
+      DASHBOARD_VERSION: ${{ github.event.inputs.version }}
+    permissions:
+      contents: write
+      pull-requests: write
+
+    steps:
+      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+
+      - name: Create PR to update dashboard version in Makefile
+        run: |
+          set -euxo pipefail
+          git config --global user.name "${GITHUB_ACTOR}"
+          git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git fetch origin
+          BASE_BRANCH="$(git branch --remotes --list 'origin/release-5?' | sort -r | head -n 1 | cut -d '/' -f 2)"
+          NEW_BRANCH="bump-${EMQX_NAME}-dashboard-version-$(date +"%Y%m%d-%H%M%S")"
+          git checkout -b ${NEW_BRANCH} --track origin/${BASE_BRANCH}
+
+          case "${EMQX_NAME}" in
+            emqx)
+              sed -i "s|EMQX_DASHBOARD_VERSION=.*|EMQX_DASHBOARD_VERSION=${DASHBOARD_VERSION}|" Makefile
+              ;;
+            emqx-enterprise)
+              sed -i "s|EMQX_EE_DASHBOARD_VERSION=.*|EMQX_EE_DASHBOARD_VERSION=${DASHBOARD_VERSION}|" Makefile
+              ;;
+          esac
+          git add Makefile
+          git commit -m "chore: bump dashboard version"
+          git push origin ${NEW_BRANCH}:${NEW_BRANCH}
+          for pr in $(gh pr list --state open --base ${BASE_BRANCH} --label bump-dashboard-version --search "bump ${EMQX_NAME} dashboard version in:title" --repo ${{ github.repository }} --json number --jq '.[] | .number'); do
+            gh pr close $pr --repo ${{ github.repository }} --delete-branch || true
+          done
+          gh pr create --title "bump ${EMQX_NAME} dashboard version" --body '' --base ${BASE_BRANCH} --head ${NEW_BRANCH} --label bump-dashboard-version --repo ${{ github.repository }}