4
4
push :
5
5
branches : [ feature/*, bugfix/* ]
6
6
7
- # git ls-remote <URL> | head -1 | sed "s/HEAD//"
8
7
jobs :
9
- # isolate signing & repo cloning from docker image
10
8
auto-pr :
11
9
name : Automated Master Branch PR
12
10
runs-on : ubuntu-20.04
@@ -22,22 +20,40 @@ jobs:
22
20
- name : Extract branch name on pull request
23
21
shell : bash
24
22
run : |
25
- echo "RELEASE_VER=$(grep -Fn -m 1 'Release: ' ./RELEASE.md | rev | cut -d ":" -f1 | rev | xargs | tr -dc '[:alnum:]\-\.' || echo '')" >> $GITHUB_ENV
26
- echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
23
+ chmod -v 777 ./RELEASE.md
24
+ RELEASE_VER="$(grep -Fn -m 1 'Release: ' ./RELEASE.md | rev | cut -d ":" -f1 | rev | xargs | tr -dc '[:alnum:]\-\.' || echo '' | xargs)"
25
+ echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV
26
+ echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
27
27
echo "MASTER_REF=$(git ls-remote https://github.com/kiracore/${{ github.event.repository.name }} | head -1 | sed 's/HEAD//')" >> $GITHUB_ENV
28
+ git show-branch "remotes/origin/$RELEASE_VER" && echo "TARGET_BRANCH_EXISTS=true" >> $GITHUB_ENV || echo "TARGET_BRANCH_EXISTS=false" >> $GITHUB_ENV
28
29
- name : Print debug data before publishing
29
30
run : |
30
31
echo "Source branch: ${{ env.SOURCE_BRANCH }}"
31
32
echo " Master ref.: ${{ env.MASTER_REF }}"
32
33
echo " Release ver.: ${{ env.RELEASE_VER }}"
33
34
echo " Event name: ${{ github.event_name }}"
34
- echo " Repo. name: ${{ github.event.repository.name }}"
35
+ echo " Repo. name: ${{ github.event.repository.name }}"
36
+ echo "Target Exists: ${{ env.TARGET_BRANCH_EXISTS }}"
35
37
# ref.: https://github.com/peterjgrainger/action-create-branch, v2.0.1
36
38
- name : Create version branch from master
37
39
uses : peterjgrainger/action-create-branch@40d33f921267ca130cbacc770f41fc7c501a420f
38
- if : startsWith(env.RELEASE_VER, 'v') && contains(env.RELEASE_VER, '.')
40
+ if : |
41
+ ( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) &&
42
+ ( startsWith(env.RELEASE_VER, 'v') && contains(env.RELEASE_VER, '.') )
39
43
env :
40
44
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41
45
with :
42
46
branch : ${{ env.RELEASE_VER }}
43
47
sha : ${{ env.MASTER_REF }}
48
+ - name : Create PR from feature to version branch
49
+ if : |
50
+ ( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) &&
51
+ ( startsWith(env.RELEASE_VER, 'v') && contains(env.RELEASE_VER, '.') )
52
+ uses : repo-sync/pull-request@5ba2c80b97c87b9174c1548141b7acd80f6376e1
53
+ with :
54
+ github_token : ${{ secrets.REPO_ACCESS }}
55
+ source_branch : ${{ env.SOURCE_BRANCH }}
56
+ destination_branch : ${{ env.RELEASE_VER}}
57
+ pr_title : " ${{ env.SOURCE_BRANCH }} -> ${{ env.RELEASE_VER }}"
58
+ pr_label : " kira-automation"
59
+ pr_allow_empty : true
0 commit comments