-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (57 loc) · 2.35 KB
/
bump-dashboard-version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Create PR to update dashboard version in Makefile
env:
GH_TOKEN: ${{ github.token }}
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 }}