-
Notifications
You must be signed in to change notification settings - Fork 309
89 lines (74 loc) · 2.33 KB
/
rebase-release-proposal.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Rebase release proposal
on:
workflow_dispatch:
inputs:
base-branch:
description: 'Branch to rebase onto'
required: true
type: choice
options:
- v4.x
- v5.x
jobs:
check:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get PR details
id: get_pr
run: |
pr_number=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Check PR approval
id: check_approval
run: |
approvals=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \
| jq '[.[] | select(.state == "APPROVED")] | length')
if [ "$approvals" -eq 0 ]; then
exit 1
fi
- name: Check CI status
id: check_ci_status
run: |
status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/status" \
| jq -r '.state')
if [ "$status" != "success" ]; then
exit 1
fi
release:
needs: check
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN_RELEASE }}
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Checkout base branch
run: |
git checkout ${{ github.event.inputs.base-branch }}
- name: Rebase branch
run: |
git rebase ${{ github.ref_name }}
- name: Push rebased branch
run: |
git push