Skip to content

Commit c20aac9

Browse files
authored
chore: add fast-forward workflows (#49)
* chore: add fast-forward workflows * chore: fast forward actions v2 * feat: change label name * lint
1 parent 35bc5a2 commit c20aac9

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Fast Forward Check Workflow
2+
# This workflow validates pull requests with the 'fast-forward' label to ensure they follow
3+
# the correct branch hierarchy before allowing fast-forward merging:
4+
# - PRs targeting 'bepolia' must come from 'devel' branch
5+
# - PRs targeting 'main' must come from 'bepolia' branch
6+
# The workflow runs on PR events and validates branch structure without merging.
7+
8+
name: check-fast-forward
9+
on:
10+
pull_request:
11+
types: [opened, edited, labeled, synchronize]
12+
branches:
13+
- main
14+
- bepolia
15+
jobs:
16+
check-fast-forward:
17+
runs-on: ubuntu-latest
18+
19+
if: ${{ contains(github.event.pull_request.labels.*.name, 'fast-forward') }}
20+
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
issues: write
25+
26+
steps:
27+
- name: Validate branches
28+
run: |
29+
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
30+
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
31+
if [ "$GITHUB_BASE_REF" == "bepolia" ] && [ "$GITHUB_HEAD_REF" != "devel" ]; then
32+
echo "Error: When targeting bepolia branch, head branch must be devel"
33+
exit 1
34+
elif [ "$GITHUB_BASE_REF" == "main" ] && [ "$GITHUB_HEAD_REF" != "bepolia" ]; then
35+
echo "Error: When targeting main branch, head branch must be bepolia"
36+
exit 1
37+
fi
38+
39+
- name: Fast forwarding
40+
uses: sequoia-pgp/fast-forward@v1
41+
with:
42+
merge: false
43+
comment: on-error # always | never | on-error

.github/workflows/fast-forward.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Fast Forward Workflow
2+
# This workflow automatically fast-forwards pull requests with the 'fast-forward' label
3+
# when they receive an approved review. It ensures proper branch hierarchy:
4+
# - PRs targeting 'bepolia' must come from 'devel' branch
5+
# - PRs targeting 'main' must come from 'bepolia' branch
6+
# The workflow uses sequoia-pgp/fast-forward action to merge changes automatically.
7+
8+
name: execute-fast-forward
9+
on:
10+
pull_request_review:
11+
types: [submitted]
12+
branches:
13+
- main
14+
- bepolia
15+
jobs:
16+
execute-fast-forward:
17+
runs-on: ubuntu-latest
18+
19+
if:
20+
${{ contains(github.event.pull_request.labels.*.name, 'fast-forward') && github.event.review.state == 'approved'
21+
}}
22+
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
issues: write
27+
28+
steps:
29+
- name: Validate branches
30+
run: |
31+
echo "GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}"
32+
echo "GITHUB_HEAD_REF: ${{ github.event.pull_request.head.ref }}"
33+
if [ ${{ github.event.pull_request.base.ref }} == "bepolia" ] && [ ${{ github.event.pull_request.head.ref }} != "devel" ]; then
34+
echo "Error: When targeting bepolia branch, head branch must be devel"
35+
exit 1
36+
elif [ ${{ github.event.pull_request.base.ref }} == "main" ] && [ ${{ github.event.pull_request.head.ref }} != "bepolia" ]; then
37+
echo "Error: When targeting main branch, head branch must be bepolia"
38+
exit 1
39+
fi
40+
- name: Fast forwarding
41+
uses: sequoia-pgp/fast-forward@v1
42+
with:
43+
merge: true
44+
comment: on-error # always | never | on-error

.github/workflows/tests-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
- devel
87
- bepolia
8+
- devel
99

1010
jobs:
1111
test:

0 commit comments

Comments
 (0)