Skip to content

Commit 6f893b9

Browse files
committed
workflow: Add workflow to auto-update the unity version badge in README.md.
1 parent db52736 commit 6f893b9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unity Version Badge
2+
3+
on:
4+
push:
5+
paths:
6+
- 'ProjectSettings/ProjectVersion.txt'
7+
workflow_dispatch:
8+
9+
jobs:
10+
update-badge:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Read Unity Version
17+
id: read_unity_version
18+
run: |
19+
unity_version=$(grep -oP 'm_EditorVersion: \K.*' ProjectSettings/ProjectVersion.txt)
20+
echo "UNITY_VERSION=$unity_version" >> $GITHUB_ENV
21+
22+
- name: Update README with Badge
23+
run: |
24+
badge_url="https://img.shields.io/badge/Unity-$UNITY_VERSION-brightgreen"
25+
sed -i 's|!\[Unity\](.*)|![Unity]('"$badge_url"')|' README.md
26+
27+
- name: Commit changes
28+
run: |
29+
git config --global user.name 'github-actions'
30+
git config --global user.email '[email protected]'
31+
git add README.md
32+
git commit -m "Update Unity version badge to $UNITY_VERSION"
33+
git push

0 commit comments

Comments
 (0)