Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3d0a7f6

Browse files
authored
Add action to auto merge dependabot pr's (#72)
The action CI has following features: - automatic versioning - build compatibility checking - automatic merging
1 parent 88e6805 commit 3d0a7f6

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI for testing and merging Dependabot updates
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
11+
jobs:
12+
updateversion:
13+
name: updateversion
14+
runs-on: ubuntu-latest
15+
if: github.actor == 'dependabot[bot]'
16+
steps:
17+
- name: checkout
18+
uses: actions/checkout@v2
19+
20+
- name: increment last version digit
21+
run: |
22+
old=$(grep -P "(?<=VERSION_NAME=).*" gradle.properties")
23+
lastnumber=$(echo $old | grep -Po "\d*$")
24+
new=$(echo $old | grep -Po ".+?(?=$lastnumber)")
25+
new+=$((lastnumber+1))
26+
sed -i "s/${old}/${new}/" gradle.properties
27+
28+
- name: create commit
29+
uses: stefanzweifel/git-auto-commit-action@v4
30+
with:
31+
commit_message: Automated version incerment
32+
file_pattern: gradle.properties
33+
34+
build:
35+
name: build
36+
needs: updateversion
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: checkout
40+
uses: actions/checkout@v2
41+
42+
- name: java setup and gradle caching
43+
uses: actions/setup-java@v2
44+
with:
45+
distribution: "zulu"
46+
java-version: "11"
47+
cache: "gradle"
48+
49+
- name: grant execute permission for gradlew
50+
run: chmod +x gradlew
51+
52+
- name: assemble release
53+
run: ./gradlew -p ./yanndroid/oneui assembleRelease
54+
55+
merge:
56+
name: merge
57+
needs: build
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: merge dependabot pull_reuqest
61+
run: gh pr merge --auto --merge "$PR_URL"
62+
env:
63+
PR_URL: ${{github.event.pull_request.html_url}}
64+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)