-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (42 loc) · 1.69 KB
/
test.yml
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
name: Update Dependabot Configuration
on:
push:
branches:
- 'release/*.0'
jobs:
update-dependabot:
if: github.event.created
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: "main"
token: ${{secrets.GH_TOKEN}}
- name: Get Branch Name
id: branch_name
run: echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Update Dependabot Configuration
env:
new_release_branch_name: "${{ steps.branch_name.outputs.branch_name }}"
run: |
IFS='.' read -r -a version_parts <<< "$new_release_branch_name"
major="${version_parts[0]}"
minor="${version_parts[1]}"
patch="${version_parts[2]}"
# Increment the minor version
minor=$((minor + 1))
# Construct the new version string with "_DEV" suffix
new_version="$major.$minor""_DEV"
echo "New version: $new_version"
branch="$new_version""_BRANCH"
git checkout -b $branch
sed -i "s#\(^ *target-branch: \).*#\1\"$new_version\"#" .github/dependabot.yml
echo ${{ secrets.GH_TOKEN }} | gh auth login --hostname github.com --with-token
# Commit and push the changes
git config user.email "[email protected]"
git config user.name "GitHub Actions"
git add .github/dependabot.yml
git commit -m "Update Dependabot target_branch to $new_version"
git push origin $branch
gh pr create --base test -H $branch --title "Update Dependabot target_branch to $new_version" --body "Created by Github action"