forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (43 loc) · 1.58 KB
/
pr-version-check.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: PR latest version check
on:
pull_request:
types: [synchronize]
jobs:
check-latest-version:
name: Check latest version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: get package version
id: package-version
uses: martinbeentjes/[email protected]
- name: check version
id: check-version
run: |
echo "Check if the version name has changed"
echo "Using repository: ${{ github.repository }}"
gh repo set-default ${{ github.repository }}
TITLE=$(gh pr view ${{ github.event.number }} --json title --jq '.title')
IS_RELEASE_PR=$(echo $TITLE | grep 'release:' | wc -l)
COUNT=$(echo $TITLE | grep '${{ steps.package-version.outputs.current-version }}' | wc -l)
if [ $((IS_RELEASE_PR)) -eq 0 ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "This PR is not a release PR"
exit 0
fi
if [ $((COUNT)) -gt 0 ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Version already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Version does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: update pr
if: steps.check-version.outputs.exists == 'false'
shell: bash
run: |
gh pr edit ${{ github.event.number }} -t "release: v${{ steps.package-version.outputs.current-version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}