Skip to content

Commit adaa1ef

Browse files
authored
Add branch_alias.yml for all packages (#779)
1 parent 1547744 commit adaa1ef

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/branch_alias.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Update branch alias
2+
3+
on:
4+
push:
5+
tags: ['*']
6+
7+
jobs:
8+
branch-alias:
9+
name: Update branch alias
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@2.5.0
15+
with:
16+
php-version: 7.4
17+
coverage: none
18+
19+
- name: Find branch alias
20+
id: find_alias
21+
run: |
22+
TAG=$(echo $GITHUB_REF | cut -d'/' -f 3)
23+
echo "Last tag was $TAG"
24+
ARR=(${TAG//./ })
25+
ARR[1]=$((${ARR[1]}+1))
26+
echo ::set-output name=alias::${ARR[0]}.${ARR[1]}
27+
28+
- name: Checkout main repo
29+
run: |
30+
git clone --branch master https://${{ secrets.BOT_GITHUB_TOKEN }}:x-oauth-basic@github.com/async-aws/aws aws
31+
32+
- name: Update branch alias
33+
run: |
34+
cd aws/src/Integration/Laravel/Queue
35+
CURRENT_ALIAS=$(composer config extra.branch-alias.dev-master | cut -d'-' -f 1)
36+
37+
# If there is a current value on the branch alias
38+
if [ ! -z $CURRENT_ALIAS ]; then
39+
NEW_ALIAS=${{ steps.find_alias.outputs.alias }}
40+
CURRENT_ARR=(${CURRENT_ALIAS//./ })
41+
NEW_ARR=(${NEW_ALIAS//./ })
42+
43+
if [ ${CURRENT_ARR[0]} -gt ${NEW_ARR[0]} ]; then
44+
echo "The current value for major version is larger"
45+
exit 1;
46+
fi
47+
48+
if [ ${CURRENT_ARR[1]} -gt ${NEW_ARR[1]} ]; then
49+
echo "The current value for minor version is larger"
50+
exit 1;
51+
fi
52+
fi
53+
54+
composer config extra.branch-alias.dev-master ${{ steps.find_alias.outputs.alias }}-dev
55+
56+
- name: Commit & push the new files
57+
run: |
58+
echo "::group::git status"
59+
cd aws
60+
git status
61+
echo "::endgroup::"
62+
63+
git add -N .
64+
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then
65+
echo "No changes found. Exiting."
66+
exit 0;
67+
fi
68+
69+
git config --local user.email "github@async-aws.com"
70+
git config --local user.name "AsyncAws Bot"
71+
72+
echo "::group::git push"
73+
git add .
74+
git commit -m "Update branch alias"
75+
git push
76+
echo "::endgroup::"

0 commit comments

Comments
 (0)