File tree Expand file tree Collapse file tree 2 files changed +59
-1
lines changed
charts/hwameistor-operator Expand file tree Collapse file tree 2 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Auto Commit with Custom Branch
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ branch_name :
7+ description : ' Enter the new branch name'
8+ required : true
9+ type : string
10+
11+ jobs :
12+ execute-and-commit :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout main branch
16+ uses : actions/checkout@v4
17+ with :
18+ ref : main
19+
20+ - name : Execute test.sh with input
21+ run : |
22+ chmod +x ./charts/hwameistor-operator/upgrade_hwameistor-operator.s
23+ ./charts/hwameistor-operator/upgrade_hwameistor-operator.sh "${{ github.event.inputs.branch_name }}"
24+
25+ - name : Configure Git User
26+ run : |
27+ git config --global user.name "GitHub Actions"
28+ git config --global user.email "actions@github.com"
29+
30+ - name : Create and Push Custom Branch
31+ run : |
32+
33+ NEW_BRANCH="${{ github.event.inputs.branch_name }}"
34+
35+
36+ if [[ ! "$NEW_BRANCH" =~ ^[a-zA-Z0-9_-]+$ ]]; then
37+ echo "Error: Invalid branch name!"
38+ exit 1
39+ fi
40+
41+
42+ if git ls-remote --exit-code --heads origin "$NEW_BRANCH"; then
43+ echo "Error: Branch $NEW_BRANCH already exists!"
44+ exit 1
45+ fi
46+
47+ git checkout -b "$NEW_BRANCH"
48+
49+ if git status --porcelain; then
50+ git add .
51+ git commit -m "Auto-commit: $NEW_BRANCH"
52+ git push origin "$NEW_BRANCH"
53+ echo "Successfully pushed to $NEW_BRANCH"
54+ else
55+ echo "No changes to commit"
56+ fi
57+ env :
58+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
Original file line number Diff line number Diff line change 22# # hwameistor-operator repo: https://github.com/hwameistor/hwameistor-operator
33
44# /bin/bash
5-
5+ set -x
66releaseVersion=$1
77
88[ " $releaseVersion " == " " ] && \
You can’t perform that action at this time.
0 commit comments