-
Notifications
You must be signed in to change notification settings - Fork 36
61 lines (58 loc) · 1.78 KB
/
Copy pathpr.yml
File metadata and controls
61 lines (58 loc) · 1.78 KB
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
53
54
55
56
57
58
59
60
61
name: PR
run-name: PR
on:
pull_request:
types: [opened, reopened, labeled, synchronize]
jobs:
CI:
uses: ./.github/workflows/ci.yml
Auto-Merge:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
needs: CI
outputs:
auto_release: ${{ steps.auto-merge.outputs.auto_release }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Auto-merge
id: auto-merge
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
prnum=$(jq --raw-output '.pull_request.number' "$GITHUB_EVENT_PATH")
author=$(gh pr view "$prnum" --json 'author' --jq '.author.login')
prsha='${{ github.event.pull_request.head.sha }}'
git fetch --depth=1 origin master
git fetch --depth=10 origin bot || exit 0
echo "AUTHOR: $author"
echo "PRSHA: $prsha"
echo "FETCH_HEAD: $(git rev-parse FETCH_HEAD)"
if [ "$author" == "app/github-actions" ] && [ "$prsha" == "$(git rev-parse FETCH_HEAD)" ]; then
git checkout master
git merge origin/bot
git push
if git log -1 --pretty="format:" --name-only | grep -q '^version.txt$'; then
echo "auto_release=1" >> "$GITHUB_OUTPUT"
fi
fi
Auto-Release:
permissions:
actions: write
runs-on: ubuntu-latest
needs: Auto-Merge
if: ${{ needs.Auto-Merge.outputs.auto_release }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Auto-release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh workflow run release.yml